This source file includes following definitions.
- for_character
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <config.h>
18
19 #include <uchar.h>
20
21 #include "signature.h"
22 SIGNATURE_CHECK (c32isspace, int, (wint_t));
23
24 #include <locale.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <wchar.h>
28
29 #include "macros.h"
30
31
32 static int
33 for_character (const char *s, size_t n)
34 {
35 mbstate_t state;
36 char32_t wc;
37 size_t ret;
38
39 memset (&state, '\0', sizeof (mbstate_t));
40 wc = (char32_t) 0xBADFACE;
41 ret = mbrtoc32 (&wc, s, n, &state);
42 ASSERT (ret == n);
43
44 return c32isspace (wc);
45 }
46
47 int
48 main (int argc, char *argv[])
49 {
50 int is;
51 char buf[4];
52
53
54 if (setlocale (LC_ALL, "") == NULL)
55 return 1;
56
57
58 is = c32isspace (WEOF);
59 ASSERT (is == 0);
60
61
62
63
64
65
66
67
68
69
70
71 {
72 int c;
73
74 for (c = 0; c < 0x100; c++)
75 switch (c)
76 {
77 case '\f': case '\n': case '\r': case '\t': case '\v':
78 case ' ': case '!': case '"': case '#': case '%':
79 case '&': case '\'': case '(': case ')': case '*':
80 case '+': case ',': case '-': case '.': case '/':
81 case '0': case '1': case '2': case '3': case '4':
82 case '5': case '6': case '7': case '8': case '9':
83 case ':': case ';': case '<': case '=': case '>':
84 case '?':
85 case 'A': case 'B': case 'C': case 'D': case 'E':
86 case 'F': case 'G': case 'H': case 'I': case 'J':
87 case 'K': case 'L': case 'M': case 'N': case 'O':
88 case 'P': case 'Q': case 'R': case 'S': case 'T':
89 case 'U': case 'V': case 'W': case 'X': case 'Y':
90 case 'Z':
91 case '[': case '\\': case ']': case '^': case '_':
92 case 'a': case 'b': case 'c': case 'd': case 'e':
93 case 'f': case 'g': case 'h': case 'i': case 'j':
94 case 'k': case 'l': case 'm': case 'n': case 'o':
95 case 'p': case 'q': case 'r': case 's': case 't':
96 case 'u': case 'v': case 'w': case 'x': case 'y':
97 case 'z': case '{': case '|': case '}': case '~':
98
99
100 buf[0] = (unsigned char) c;
101 is = for_character (buf, 1);
102 switch (c)
103 {
104 case ' ': case '\f': case '\n': case '\r': case '\t': case '\v':
105 ASSERT (is != 0);
106 break;
107 default:
108 ASSERT (is == 0);
109 break;
110 }
111 break;
112 }
113 }
114
115 if (argc > 1)
116 switch (argv[1][0])
117 {
118 case '0':
119
120 return 0;
121
122 case '1':
123
124 {
125
126 is = for_character ("\267", 1);
127 ASSERT (is == 0);
128 }
129 return 0;
130
131 case '2':
132
133 {
134 #if !(defined __FreeBSD__ || defined __DragonFly__)
135
136 is = for_character ("\241\241", 2);
137 ASSERT (is != 0);
138 #endif
139
140 is = for_character ("\241\242", 2);
141 ASSERT (is == 0);
142 }
143 return 0;
144
145 case '3':
146
147 {
148
149 is = for_character ("\302\267", 2);
150 ASSERT (is == 0);
151
152 is = for_character ("\342\200\202", 3);
153 ASSERT (is != 0);
154
155 is = for_character ("\343\200\200", 3);
156 ASSERT (is != 0);
157
158 is = for_character ("\343\200\201", 3);
159 ASSERT (is == 0);
160
161 is = for_character ("\363\240\200\240", 4);
162 ASSERT (is == 0);
163 }
164 return 0;
165
166 case '4':
167
168 {
169
170 is = for_character ("\241\244", 2);
171 ASSERT (is == 0);
172 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun)
173
174 is = for_character ("\201\066\243\070", 4);
175 ASSERT (is != 0);
176 #endif
177 #if !(defined __FreeBSD__ || defined __DragonFly__)
178
179 is = for_character ("\241\241", 2);
180 ASSERT (is != 0);
181 #endif
182
183 is = for_character ("\241\242", 2);
184 ASSERT (is == 0);
185
186 is = for_character ("\323\066\231\060", 4);
187 ASSERT (is == 0);
188 }
189 return 0;
190
191 }
192
193 return 1;
194 }