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 <wctype.h>
20
21 #include "signature.h"
22 SIGNATURE_CHECK (iswxdigit, 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 wchar_t wc;
37 size_t ret;
38
39 memset (&state, '\0', sizeof (mbstate_t));
40 wc = (wchar_t) 0xBADFACE;
41 ret = mbrtowc (&wc, s, n, &state);
42 if (ret == n)
43 return iswxdigit (wc);
44 else
45 return 0;
46 }
47
48 int
49 main (int argc, char *argv[])
50 {
51 int is;
52 char buf[4];
53
54
55 if (setlocale (LC_ALL, "") == NULL)
56 return 1;
57
58
59 is = iswxdigit (WEOF);
60 ASSERT (is == 0);
61
62
63
64
65 {
66 int c;
67
68 for (c = 0; c < 0x100; c++)
69 switch (c)
70 {
71 case '\t': case '\v': case '\f':
72 case ' ': case '!': case '"': case '#': case '%':
73 case '&': case '\'': case '(': case ')': case '*':
74 case '+': case ',': case '-': case '.': case '/':
75 case '0': case '1': case '2': case '3': case '4':
76 case '5': case '6': case '7': case '8': case '9':
77 case ':': case ';': case '<': case '=': case '>':
78 case '?':
79 case 'A': case 'B': case 'C': case 'D': case 'E':
80 case 'F': case 'G': case 'H': case 'I': case 'J':
81 case 'K': case 'L': case 'M': case 'N': case 'O':
82 case 'P': case 'Q': case 'R': case 'S': case 'T':
83 case 'U': case 'V': case 'W': case 'X': case 'Y':
84 case 'Z':
85 case '[': case '\\': case ']': case '^': case '_':
86 case 'a': case 'b': case 'c': case 'd': case 'e':
87 case 'f': case 'g': case 'h': case 'i': case 'j':
88 case 'k': case 'l': case 'm': case 'n': case 'o':
89 case 'p': case 'q': case 'r': case 's': case 't':
90 case 'u': case 'v': case 'w': case 'x': case 'y':
91 case 'z': case '{': case '|': case '}': case '~':
92
93 buf[0] = (unsigned char) c;
94 is = for_character (buf, 1);
95 switch (c)
96 {
97 case '0': case '1': case '2': case '3': case '4':
98 case '5': case '6': case '7': case '8': case '9':
99 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
100 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
101 ASSERT (is != 0);
102 break;
103 default:
104 ASSERT (is == 0);
105 break;
106 }
107 break;
108 }
109 }
110
111 if (argc > 1)
112 switch (argv[1][0])
113 {
114 case '0':
115
116 return 0;
117
118 case '1':
119
120 {
121
122 is = for_character ("\262", 1);
123 ASSERT (is == 0);
124
125 is = for_character ("\263", 1);
126 ASSERT (is == 0);
127
128 is = for_character ("\271", 1);
129 ASSERT (is == 0);
130 }
131 return 0;
132
133 case '2':
134
135 {
136
137 is = for_character ("\243\261", 2);
138 ASSERT (is == 0);
139
140 is = for_character ("\243\301", 2);
141 ASSERT (is == 0);
142
143 is = for_character ("\243\341", 2);
144 ASSERT (is == 0);
145 }
146 return 0;
147
148 case '3':
149
150 {
151
152 is = for_character ("\302\262", 2);
153 ASSERT (is == 0);
154
155 is = for_character ("\302\263", 2);
156 ASSERT (is == 0);
157
158 is = for_character ("\302\271", 2);
159 ASSERT (is == 0);
160
161 is = for_character ("\331\243", 2);
162 ASSERT (is == 0);
163
164 is = for_character ("\342\201\260", 3);
165 ASSERT (is == 0);
166
167 is = for_character ("\342\201\271", 3);
168 ASSERT (is == 0);
169
170 is = for_character ("\357\274\221", 3);
171 ASSERT (is == 0);
172
173 is = for_character ("\357\274\241", 3);
174 ASSERT (is == 0);
175
176 is = for_character ("\357\275\201", 3);
177 ASSERT (is == 0);
178
179 is = for_character ("\360\235\237\221", 4);
180 ASSERT (is == 0);
181
182 is = for_character ("\360\235\237\233", 4);
183 ASSERT (is == 0);
184
185 is = for_character ("\360\235\237\245", 4);
186 ASSERT (is == 0);
187
188 is = for_character ("\360\235\237\257", 4);
189 ASSERT (is == 0);
190
191 is = for_character ("\360\235\237\271", 4);
192 ASSERT (is == 0);
193
194 is = for_character ("\363\240\200\263", 4);
195 ASSERT (is == 0);
196
197 is = for_character ("\363\240\201\201", 4);
198 ASSERT (is == 0);
199 }
200 return 0;
201
202 case '4':
203
204 {
205
206 is = for_character ("\201\060\205\065", 4);
207 ASSERT (is == 0);
208
209 is = for_character ("\201\060\205\066", 4);
210 ASSERT (is == 0);
211
212 is = for_character ("\201\060\206\061", 4);
213 ASSERT (is == 0);
214
215 is = for_character ("\201\061\211\071", 4);
216 ASSERT (is == 0);
217
218 is = for_character ("\201\066\255\062", 4);
219 ASSERT (is == 0);
220
221 is = for_character ("\201\066\256\061", 4);
222 ASSERT (is == 0);
223
224 is = for_character ("\243\261", 2);
225 ASSERT (is == 0);
226
227 is = for_character ("\243\301", 2);
228 ASSERT (is == 0);
229
230 is = for_character ("\243\341", 2);
231 ASSERT (is == 0);
232
233 is = for_character ("\224\063\353\071", 4);
234 ASSERT (is == 0);
235
236 is = for_character ("\224\063\354\071", 4);
237 ASSERT (is == 0);
238
239 is = for_character ("\224\063\355\071", 4);
240 ASSERT (is == 0);
241
242 is = for_character ("\224\063\356\071", 4);
243 ASSERT (is == 0);
244
245 is = for_character ("\224\063\357\071", 4);
246 ASSERT (is == 0);
247
248 is = for_character ("\323\066\232\071", 4);
249 ASSERT (is == 0);
250
251 is = for_character ("\323\066\234\063", 4);
252 ASSERT (is == 0);
253 }
254 return 0;
255
256 }
257
258 return 1;
259 }