1 /* Test of c32islower() function.
2 Copyright (C) 2020 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
21 #include "signature.h"
22 SIGNATURE_CHECK (c32islower
, int, (wint_t));
31 /* Returns the value of c32islower for the multibyte character s[0..n-1]. */
33 for_character (const char *s
, size_t n
)
39 memset (&state
, '\0', sizeof (mbstate_t));
40 wc
= (char32_t
) 0xBADFACE;
41 ret
= mbrtoc32 (&wc
, s
, n
, &state
);
44 return c32islower (wc
);
48 main (int argc
, char *argv
[])
53 /* configure should already have checked that the locale is supported. */
54 if (setlocale (LC_ALL
, "") == NULL
)
58 is
= c32islower (WEOF
);
61 /* Test single-byte characters.
63 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
65 - in all locales, the lowercase characters include the a ... z
67 - in the "POSIX" locale (which is usually the same as the "C" locale),
68 the lowercase characters include only the ASCII a ... z characters.
73 for (c
= 0; c
< 0x100; c
++)
76 case '\t': case '\v': case '\f':
77 case ' ': case '!': case '"': case '#': case '%':
78 case '&': case '\'': case '(': case ')': case '*':
79 case '+': case ',': case '-': case '.': case '/':
80 case '0': case '1': case '2': case '3': case '4':
81 case '5': case '6': case '7': case '8': case '9':
82 case ':': case ';': case '<': case '=': case '>':
84 case 'A': case 'B': case 'C': case 'D': case 'E':
85 case 'F': case 'G': case 'H': case 'I': case 'J':
86 case 'K': case 'L': case 'M': case 'N': case 'O':
87 case 'P': case 'Q': case 'R': case 'S': case 'T':
88 case 'U': case 'V': case 'W': case 'X': case 'Y':
90 case '[': case '\\': case ']': case '^': case '_':
91 case 'a': case 'b': case 'c': case 'd': case 'e':
92 case 'f': case 'g': case 'h': case 'i': case 'j':
93 case 'k': case 'l': case 'm': case 'n': case 'o':
94 case 'p': case 'q': case 'r': case 's': case 't':
95 case 'u': case 'v': case 'w': case 'x': case 'y':
96 case 'z': case '{': case '|': case '}': case '~':
97 /* c is in the ISO C "basic character set". */
98 buf
[0] = (unsigned char) c
;
99 is
= for_character (buf
, 1);
102 case 'a': case 'b': case 'c': case 'd': case 'e':
103 case 'f': case 'g': case 'h': case 'i': case 'j':
104 case 'k': case 'l': case 'm': case 'n': case 'o':
105 case 'p': case 'q': case 'r': case 's': case 't':
106 case 'u': case 'v': case 'w': case 'x': case 'y':
122 /* C locale; tested above. */
126 /* Locale encoding is ISO-8859-1 or ISO-8859-15. */
128 /* U+00B2 SUPERSCRIPT TWO */
129 is
= for_character ("\262", 1);
131 #if !(defined __GLIBC__ || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__))
132 /* U+00B5 MICRO SIGN */
133 is
= for_character ("\265", 1);
136 /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */
137 is
= for_character ("\311", 1);
139 #if !defined __CYGWIN__
140 /* U+00DF LATIN SMALL LETTER SHARP S */
141 is
= for_character ("\337", 1);
144 /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */
145 is
= for_character ("\351", 1);
147 /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */
148 is
= for_character ("\377", 1);
154 /* Locale encoding is EUC-JP. */
156 /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */
157 is
= for_character ("\217\252\261", 3);
159 #if !((defined __APPLE__ && defined __MACH__) || defined __NetBSD__ || defined __CYGWIN__)
160 /* U+00DF LATIN SMALL LETTER SHARP S */
161 is
= for_character ("\217\251\316", 3);
164 #if !((defined __APPLE__ && defined __MACH__) || defined __NetBSD__)
165 /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */
166 is
= for_character ("\217\253\261", 3);
168 /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */
169 is
= for_character ("\217\253\363", 3);
172 /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */
173 is
= for_character ("\217\251\250", 3);
175 #if !((defined __APPLE__ && defined __MACH__) || defined __NetBSD__)
176 /* U+0142 LATIN SMALL LETTER L WITH STROKE */
177 is
= for_character ("\217\251\310", 3);
180 /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */
181 is
= for_character ("\247\273", 2);
183 #if !(defined __FreeBSD__ || defined __DragonFly__)
184 /* U+0449 CYRILLIC SMALL LETTER SHCHA */
185 is
= for_character ("\247\353", 2);
188 /* U+3073 HIRAGANA LETTER BI */
189 is
= for_character ("\244\323", 2);
191 /* U+FF47 FULLWIDTH LATIN SMALL LETTER G */
192 is
= for_character ("\243\347", 2);
198 /* Locale encoding is UTF-8. */
200 /* U+00B2 SUPERSCRIPT TWO */
201 is
= for_character ("\302\262", 2);
203 #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__))
204 /* U+00B5 MICRO SIGN */
205 is
= for_character ("\302\265", 2);
208 /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */
209 is
= for_character ("\303\211", 2);
211 #if !defined __CYGWIN__
212 /* U+00DF LATIN SMALL LETTER SHARP S */
213 is
= for_character ("\303\237", 2);
216 /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */
217 is
= for_character ("\303\251", 2);
219 /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */
220 is
= for_character ("\303\277", 2);
222 /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */
223 is
= for_character ("\305\201", 2);
225 /* U+0142 LATIN SMALL LETTER L WITH STROKE */
226 is
= for_character ("\305\202", 2);
228 /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */
229 is
= for_character ("\320\251", 2);
231 /* U+0449 CYRILLIC SMALL LETTER SHCHA */
232 is
= for_character ("\321\211", 2);
234 /* U+05D5 HEBREW LETTER VAV */
235 is
= for_character ("\327\225", 2);
237 /* U+3073 HIRAGANA LETTER BI */
238 is
= for_character ("\343\201\263", 3);
240 /* U+3162 HANGUL LETTER YI */
241 is
= for_character ("\343\205\242", 3);
243 /* U+FF47 FULLWIDTH LATIN SMALL LETTER G */
244 is
= for_character ("\357\275\207", 3);
246 /* U+FFDB HALFWIDTH HANGUL LETTER YI */
247 is
= for_character ("\357\277\233", 3);
249 /* U+10419 DESERET CAPITAL LETTER EF */
250 is
= for_character ("\360\220\220\231", 4);
252 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun)
253 /* U+10441 DESERET SMALL LETTER EF */
254 is
= for_character ("\360\220\221\201", 4);
257 /* U+E0041 TAG LATIN CAPITAL LETTER A */
258 is
= for_character ("\363\240\201\201", 4);
260 /* U+E0061 TAG LATIN SMALL LETTER A */
261 is
= for_character ("\363\240\201\241", 4);
267 /* Locale encoding is GB18030. */
269 /* U+00B2 SUPERSCRIPT TWO */
270 is
= for_character ("\201\060\205\065", 4);
272 #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __NetBSD__)
273 /* U+00B5 MICRO SIGN */
274 is
= for_character ("\201\060\205\070", 4);
277 /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */
278 is
= for_character ("\201\060\207\067", 4);
280 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun)
281 /* U+00DF LATIN SMALL LETTER SHARP S */
282 is
= for_character ("\201\060\211\070", 4);
285 /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */
286 is
= for_character ("\250\246", 2);
288 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun)
289 /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */
290 is
= for_character ("\201\060\213\067", 4);
293 /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */
294 is
= for_character ("\201\060\221\071", 4);
296 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun)
297 /* U+0142 LATIN SMALL LETTER L WITH STROKE */
298 is
= for_character ("\201\060\222\060", 4);
301 /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */
302 is
= for_character ("\247\273", 2);
304 #if !(defined __FreeBSD__ || defined __DragonFly__)
305 /* U+0449 CYRILLIC SMALL LETTER SHCHA */
306 is
= for_character ("\247\353", 2);
309 /* U+05D5 HEBREW LETTER VAV */
310 is
= for_character ("\201\060\371\067", 4);
312 /* U+3073 HIRAGANA LETTER BI */
313 is
= for_character ("\244\323", 2);
315 /* U+3162 HANGUL LETTER YI */
316 is
= for_character ("\201\071\256\062", 4);
318 /* U+FF47 FULLWIDTH LATIN SMALL LETTER G */
319 is
= for_character ("\243\347", 2);
321 /* U+FFDB HALFWIDTH HANGUL LETTER YI */
322 is
= for_character ("\204\061\241\071", 4);
324 /* U+10419 DESERET CAPITAL LETTER EF */
325 is
= for_character ("\220\060\351\071", 4);
327 #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun)
328 /* U+10441 DESERET SMALL LETTER EF */
329 is
= for_character ("\220\060\355\071", 4);
332 /* U+E0041 TAG LATIN CAPITAL LETTER A */
333 is
= for_character ("\323\066\234\063", 4);
335 /* U+E0061 TAG LATIN SMALL LETTER A */
336 is
= for_character ("\323\066\237\065", 4);