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 (c32isalpha, 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 c32isalpha (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 = c32isalpha (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 '\t': case '\v': case '\f':
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 buf[0] = (unsigned char) c;
100 is = for_character (buf, 1);
101 switch (c)
102 {
103 case 'A': case 'B': case 'C': case 'D': case 'E':
104 case 'F': case 'G': case 'H': case 'I': case 'J':
105 case 'K': case 'L': case 'M': case 'N': case 'O':
106 case 'P': case 'Q': case 'R': case 'S': case 'T':
107 case 'U': case 'V': case 'W': case 'X': case 'Y':
108 case 'Z':
109 case 'a': case 'b': case 'c': case 'd': case 'e':
110 case 'f': case 'g': case 'h': case 'i': case 'j':
111 case 'k': case 'l': case 'm': case 'n': case 'o':
112 case 'p': case 'q': case 'r': case 's': case 't':
113 case 'u': case 'v': case 'w': case 'x': case 'y':
114 case 'z':
115 ASSERT (is != 0);
116 break;
117 default:
118 ASSERT (is == 0);
119 break;
120 }
121 break;
122 }
123 }
124
125 if (argc > 1)
126 switch (argv[1][0])
127 {
128 case '0':
129
130 return 0;
131
132 case '1':
133
134 {
135
136 is = for_character ("\327", 1);
137 ASSERT (is == 0);
138
139 is = for_character ("\330", 1);
140 ASSERT (is != 0);
141 }
142 return 0;
143
144 case '2':
145
146 {
147
148 is = for_character ("\241\337", 2);
149 ASSERT (is == 0);
150 #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__)
151
152 is = for_character ("\217\251\254", 3);
153 ASSERT (is != 0);
154
155 is = for_character ("\217\251\250", 3);
156 ASSERT (is != 0);
157 #endif
158
159 is = for_character ("\241\242", 2);
160 ASSERT (is == 0);
161 #if !(defined __GLIBC__ || defined __CYGWIN__)
162
163 is = for_character ("\243\261", 2);
164 ASSERT (is == 0);
165 #endif
166 #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__)
167
168 is = for_character ("\243\355", 2);
169 ASSERT (is != 0);
170 #endif
171 }
172 return 0;
173
174 case '3':
175
176 {
177
178 is = for_character ("\303\227", 2);
179 ASSERT (is == 0);
180
181 is = for_character ("\303\230", 2);
182 ASSERT (is != 0);
183
184 is = for_character ("\305\201", 2);
185 ASSERT (is != 0);
186
187 is = for_character ("\343\200\201", 3);
188 ASSERT (is == 0);
189 #if !(defined __GLIBC__ || defined _AIX || defined __sun || defined __CYGWIN__)
190
191 is = for_character ("\357\274\221", 3);
192 ASSERT (is == 0);
193 #endif
194
195 is = for_character ("\357\275\215", 3);
196 ASSERT (is != 0);
197 #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun)
198
199 is = for_character ("\360\220\214\260", 4);
200 ASSERT (is != 0);
201 #endif
202
203 is = for_character ("\360\235\204\200", 4);
204 ASSERT (is == 0);
205
206 is = for_character ("\363\240\201\241", 4);
207 ASSERT (is == 0);
208 }
209 return 0;
210
211 case '4':
212
213 {
214
215 is = for_character ("\241\301", 2);
216 ASSERT (is == 0);
217 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun)
218
219 is = for_character ("\201\060\211\061", 4);
220 ASSERT (is != 0);
221
222 is = for_character ("\201\060\221\071", 4);
223 ASSERT (is != 0);
224 #endif
225
226 is = for_character ("\241\242", 2);
227 ASSERT (is == 0);
228 #if !defined __GLIBC__
229
230 is = for_character ("\243\261", 2);
231 ASSERT (is == 0);
232 #endif
233 #if !defined __DragonFly__
234
235 is = for_character ("\243\355", 2);
236 ASSERT (is != 0);
237 #endif
238 #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun)
239
240 is = for_character ("\220\060\322\066", 4);
241 ASSERT (is != 0);
242 #endif
243
244 is = for_character ("\224\062\273\064", 4);
245 ASSERT (is == 0);
246
247 is = for_character ("\323\066\237\065", 4);
248 ASSERT (is == 0);
249 }
250 return 0;
251
252 }
253
254 return 1;
255 }