1 /* Test of c32isprint() 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 (c32isprint
, int, (wint_t));
31 /* Returns the value of c32isprint 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 c32isprint (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
= c32isprint (WEOF
);
61 /* Test single-byte characters.
63 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
64 no explicit list of printable characters. */
68 for (c
= 0; c
< 0x100; c
++)
71 #if !(defined _WIN32 && !defined __CYGWIN__)
72 case '\t': case '\v': case '\f':
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 '>':
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':
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 /* c is in the ISO C "basic character set". */
95 buf
[0] = (unsigned char) c
;
96 is
= for_character (buf
, 1);
99 case '\t': case '\v': case '\f':
114 /* C locale; tested above. */
118 /* Locale encoding is ISO-8859-1 or ISO-8859-15. */
120 /* U+007F <control> */
121 is
= for_character ("\177", 1);
123 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sgi || (defined _WIN32 && !defined __CYGWIN__))
124 /* U+00A0 NO-BREAK SPACE */
125 is
= for_character ("\240", 1);
128 #if !(defined __FreeBSD__ || defined __DragonFly__)
130 is
= for_character ("\270", 1);
137 /* Locale encoding is EUC-JP. */
139 /* U+007F <control> */
140 is
= for_character ("\177", 1);
142 #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__)
144 is
= for_character ("\217\242\261", 3);
146 /* U+3000 IDEOGRAPHIC SPACE */
147 is
= for_character ("\241\241", 2);
154 /* Locale encoding is UTF-8. */
156 /* U+007F <control> */
157 is
= for_character ("\177", 1);
159 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun || (defined _WIN32 && !defined __CYGWIN__))
160 /* U+00A0 NO-BREAK SPACE */
161 is
= for_character ("\302\240", 2);
165 is
= for_character ("\302\270", 2);
167 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun || (defined _WIN32 && !defined __CYGWIN__))
168 /* U+2002 EN SPACE */
169 is
= for_character ("\342\200\202", 3);
172 #if !(defined __GLIBC__ || defined _AIX || defined __CYGWIN__)
173 /* U+202E RIGHT-TO-LEFT OVERRIDE */
174 is
= for_character ("\342\200\256", 3);
177 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun)
178 /* U+3000 IDEOGRAPHIC SPACE */
179 is
= for_character ("\343\200\200", 3);
182 #if !(defined __GLIBC__ || defined _AIX || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__))
183 /* U+FEFF ZERO WIDTH NO-BREAK SPACE */
184 is
= for_character ("\357\273\277", 3);
188 /* U+20000 <CJK Ideograph> */
189 is
= for_character ("\360\240\200\200", 4);
192 #if !(defined __GLIBC__ || defined _AIX || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__))
193 /* U+E0001 LANGUAGE TAG */
194 is
= for_character ("\363\240\200\201", 4);
201 /* Locale encoding is GB18030. */
203 /* U+007F <control> */
204 is
= for_character ("\177", 1);
206 #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun)
207 /* U+00A0 NO-BREAK SPACE */
208 is
= for_character ("\201\060\204\062", 4);
211 is
= for_character ("\201\060\206\060", 4);
213 /* U+2002 EN SPACE */
214 is
= for_character ("\201\066\243\070", 4);
217 #if !defined __GLIBC__
218 /* U+202E RIGHT-TO-LEFT OVERRIDE */
219 is
= for_character ("\201\066\247\061", 4);
222 #if !(defined __FreeBSD__ || defined __DragonFly__)
223 /* U+3000 IDEOGRAPHIC SPACE */
224 is
= for_character ("\241\241", 2);
227 #if !defined __GLIBC__
228 /* U+FEFF ZERO WIDTH NO-BREAK SPACE */
229 is
= for_character ("\204\061\225\063", 4);
232 #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun)
233 /* U+20000 <CJK Ideograph> */
234 is
= for_character ("\225\062\202\066", 4);
237 #if !defined __GLIBC__
238 /* U+E0001 LANGUAGE TAG */
239 is
= for_character ("\323\066\225\071", 4);