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 (c32isprint, 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 c32isprint (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 = c32isprint (WEOF);
59 ASSERT (is == 0);
60
61
62
63
64
65 {
66 int c;
67
68 for (c = 0; c < 0x100; c++)
69 switch (c)
70 {
71 #if !(defined _WIN32 && !defined __CYGWIN__)
72 case '\t': case '\v': case '\f':
73 #endif
74 case ' ': case '!': case '"': case '#': case '%':
75 case '&': case '\'': case '(': case ')': case '*':
76 case '+': case ',': case '-': case '.': case '/':
77 case '0': case '1': case '2': case '3': case '4':
78 case '5': case '6': case '7': case '8': case '9':
79 case ':': case ';': case '<': case '=': case '>':
80 case '?':
81 case 'A': case 'B': case 'C': case 'D': case 'E':
82 case 'F': case 'G': case 'H': case 'I': case 'J':
83 case 'K': case 'L': case 'M': case 'N': case 'O':
84 case 'P': case 'Q': case 'R': case 'S': case 'T':
85 case 'U': case 'V': case 'W': case 'X': case 'Y':
86 case 'Z':
87 case '[': case '\\': case ']': case '^': case '_':
88 case 'a': case 'b': case 'c': case 'd': case 'e':
89 case 'f': case 'g': case 'h': case 'i': case 'j':
90 case 'k': case 'l': case 'm': case 'n': case 'o':
91 case 'p': case 'q': case 'r': case 's': case 't':
92 case 'u': case 'v': case 'w': case 'x': case 'y':
93 case 'z': case '{': case '|': case '}': case '~':
94
95 buf[0] = (unsigned char) c;
96 is = for_character (buf, 1);
97 switch (c)
98 {
99 case '\t': case '\v': case '\f':
100 ASSERT (is == 0);
101 break;
102 default:
103 ASSERT (is != 0);
104 break;
105 }
106 break;
107 }
108 }
109
110 if (argc > 1)
111 switch (argv[1][0])
112 {
113 case '0':
114
115 return 0;
116
117 case '1':
118
119 {
120
121 is = for_character ("\177", 1);
122 ASSERT (is == 0);
123 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sgi || (defined _WIN32 && !defined __CYGWIN__))
124
125 is = for_character ("\240", 1);
126 ASSERT (is != 0);
127 #endif
128 #if !(defined __FreeBSD__ || defined __DragonFly__)
129
130 is = for_character ("\270", 1);
131 ASSERT (is != 0);
132 #endif
133 }
134 return 0;
135
136 case '2':
137
138 {
139
140 is = for_character ("\177", 1);
141 ASSERT (is == 0);
142 #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__)
143
144 is = for_character ("\217\242\261", 3);
145 ASSERT (is != 0);
146
147 is = for_character ("\241\241", 2);
148 ASSERT (is != 0);
149 #endif
150 }
151 return 0;
152
153 case '3':
154
155 {
156
157 is = for_character ("\177", 1);
158 ASSERT (is == 0);
159 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun || (defined _WIN32 && !defined __CYGWIN__))
160
161 is = for_character ("\302\240", 2);
162 ASSERT (is != 0);
163 #endif
164
165 is = for_character ("\302\270", 2);
166 ASSERT (is != 0);
167 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun || (defined _WIN32 && !defined __CYGWIN__))
168
169 is = for_character ("\342\200\202", 3);
170 ASSERT (is != 0);
171 #endif
172 #if !(defined __GLIBC__ || defined _AIX || defined __sun || defined __CYGWIN__)
173
174 is = for_character ("\342\200\256", 3);
175 ASSERT (is == 0);
176 #endif
177 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun)
178
179 is = for_character ("\343\200\200", 3);
180 ASSERT (is != 0);
181 #endif
182 #if !(defined __GLIBC__ || defined _AIX || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__))
183
184 is = for_character ("\357\273\277", 3);
185 ASSERT (is == 0);
186 #endif
187 #if !defined __sun
188
189 is = for_character ("\360\240\200\200", 4);
190 ASSERT (is != 0);
191 #endif
192 #if !(defined __GLIBC__ || defined _AIX || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__))
193
194 is = for_character ("\363\240\200\201", 4);
195 ASSERT (is == 0);
196 #endif
197 }
198 return 0;
199
200 case '4':
201
202 {
203
204 is = for_character ("\177", 1);
205 ASSERT (is == 0);
206 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun)
207
208 is = for_character ("\201\060\204\062", 4);
209 ASSERT (is != 0);
210
211 is = for_character ("\201\060\206\060", 4);
212 ASSERT (is != 0);
213
214 is = for_character ("\201\066\243\070", 4);
215 ASSERT (is != 0);
216 #endif
217 #if !defined __GLIBC__
218
219 is = for_character ("\201\066\247\061", 4);
220 ASSERT (is == 0);
221 #endif
222 #if !(defined __FreeBSD__ || defined __DragonFly__)
223
224 is = for_character ("\241\241", 2);
225 ASSERT (is != 0);
226 #endif
227 #if !defined __GLIBC__
228
229 is = for_character ("\204\061\225\063", 4);
230 ASSERT (is == 0);
231 #endif
232 #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun)
233
234 is = for_character ("\225\062\202\066", 4);
235 ASSERT (is != 0);
236 #endif
237 #if !defined __GLIBC__
238
239 is = for_character ("\323\066\225\071", 4);
240 ASSERT (is == 0);
241 #endif
242 }
243 return 0;
244
245 }
246
247 return 1;
248 }