1 /* Test of c32isalpha() 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 (c32isalpha
, int, (wint_t));
31 /* Returns the value of c32isalpha 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 c32isalpha (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
= c32isalpha (WEOF
);
61 /* Test single-byte characters.
63 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
65 - in all locales, the alphabetic characters include the uppercase and
66 lowercase characters and, consequently, include the A ... Z and a ... z
68 - in the "POSIX" locale (which is usually the same as the "C" locale),
69 the alphabetic characters include only the ASCII A ... Z and a ... z
74 for (c
= 0; c
< 0x100; c
++)
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 '>':
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':
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 /* c is in the ISO C "basic character set". */
99 buf
[0] = (unsigned char) c
;
100 is
= for_character (buf
, 1);
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':
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':
129 /* C locale; tested above. */
133 /* Locale encoding is ISO-8859-1 or ISO-8859-15. */
135 /* U+00D7 MULTIPLICATION SIGN */
136 is
= for_character ("\327", 1);
138 /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */
139 is
= for_character ("\330", 1);
145 /* Locale encoding is EUC-JP. */
147 /* U+00D7 MULTIPLICATION SIGN */
148 is
= for_character ("\241\337", 2);
150 #if !(defined __APPLE__ && defined __MACH__)
151 /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */
152 is
= for_character ("\217\251\254", 3);
154 /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */
155 is
= for_character ("\217\251\250", 3);
158 /* U+3001 IDEOGRAPHIC COMMA */
159 is
= for_character ("\241\242", 2);
161 #if !(defined __GLIBC__ || defined __CYGWIN__)
162 /* U+FF11 FULLWIDTH DIGIT ONE */
163 is
= for_character ("\243\261", 2);
166 #if !((defined __APPLE__ && defined __MACH__) || defined __NetBSD__)
167 /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */
168 is
= for_character ("\243\355", 2);
175 /* Locale encoding is UTF-8. */
177 /* U+00D7 MULTIPLICATION SIGN */
178 is
= for_character ("\303\227", 2);
180 /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */
181 is
= for_character ("\303\230", 2);
183 /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */
184 is
= for_character ("\305\201", 2);
186 /* U+3001 IDEOGRAPHIC COMMA */
187 is
= for_character ("\343\200\201", 3);
189 #if !(defined __GLIBC__ || defined _AIX || defined __sun || defined __CYGWIN__)
190 /* U+FF11 FULLWIDTH DIGIT ONE */
191 is
= for_character ("\357\274\221", 3);
194 /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */
195 is
= for_character ("\357\275\215", 3);
197 #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun)
198 /* U+10330 GOTHIC LETTER AHSA */
199 is
= for_character ("\360\220\214\260", 4);
202 /* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */
203 is
= for_character ("\360\235\204\200", 4);
205 /* U+E0061 TAG LATIN SMALL LETTER A */
206 is
= for_character ("\363\240\201\241", 4);
212 /* Locale encoding is GB18030. */
214 /* U+00D7 MULTIPLICATION SIGN */
215 is
= for_character ("\241\301", 2);
217 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun)
218 /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */
219 is
= for_character ("\201\060\211\061", 4);
221 /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */
222 is
= for_character ("\201\060\221\071", 4);
225 /* U+3001 IDEOGRAPHIC COMMA */
226 is
= for_character ("\241\242", 2);
228 #if !defined __GLIBC__
229 /* U+FF11 FULLWIDTH DIGIT ONE */
230 is
= for_character ("\243\261", 2);
233 /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */
234 is
= for_character ("\243\355", 2);
236 #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun)
237 /* U+10330 GOTHIC LETTER AHSA */
238 is
= for_character ("\220\060\322\066", 4);
241 /* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */
242 is
= for_character ("\224\062\273\064", 4);
244 /* U+E0061 TAG LATIN SMALL LETTER A */
245 is
= for_character ("\323\066\237\065", 4);