1 /* Test of c32isblank() 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 (c32isblank
, int, (wint_t));
31 /* Returns the value of c32isblank 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 c32isblank (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
= c32isblank (WEOF
);
61 /* Test single-byte characters.
63 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
65 - in all locales, the blank characters include the <space> and <tab>
67 - in the "POSIX" locale (which is usually the same as the "C" locale),
68 the blank characters include only the ASCII <space> and <tab>
73 for (c
= 0; c
< 0x100; c
++)
77 #if !defined __NetBSD__
81 case ' ': case '!': case '"': case '#': case '%':
82 case '&': case '\'': case '(': case ')': case '*':
83 case '+': case ',': case '-': case '.': case '/':
84 case '0': case '1': case '2': case '3': case '4':
85 case '5': case '6': case '7': case '8': case '9':
86 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':
94 case '[': case '\\': case ']': case '^': case '_':
95 case 'a': case 'b': case 'c': case 'd': case 'e':
96 case 'f': case 'g': case 'h': case 'i': case 'j':
97 case 'k': case 'l': case 'm': case 'n': case 'o':
98 case 'p': case 'q': case 'r': case 's': case 't':
99 case 'u': case 'v': case 'w': case 'x': case 'y':
100 case 'z': case '{': case '|': case '}': case '~':
101 /* c is in the ISO C "basic character set". */
102 buf
[0] = (unsigned char) c
;
103 is
= for_character (buf
, 1);
104 if (c
== '\t' || c
== ' ')
116 /* C locale; tested above. */
120 /* Locale encoding is ISO-8859-1 or ISO-8859-15. */
122 #if defined __GLIBC__
123 /* U+00A0 NO-BREAK SPACE */
124 is
= for_character ("\240", 1);
127 /* U+00B7 MIDDLE DOT */
128 is
= for_character ("\267", 1);
134 /* Locale encoding is EUC-JP. */
136 /* U+3002 IDEOGRAPHIC FULL STOP */
137 is
= for_character ("\241\243", 2);
143 /* Locale encoding is UTF-8. */
145 #if defined __GLIBC__
146 /* U+00A0 NO-BREAK SPACE */
147 is
= for_character ("\302\240", 2);
150 /* U+00B7 MIDDLE DOT */
151 is
= for_character ("\302\267", 2);
153 #if defined __GLIBC__
154 /* U+202F NARROW NO-BREAK SPACE */
155 is
= for_character ("\342\200\257", 3);
158 /* U+3002 IDEOGRAPHIC FULL STOP */
159 is
= for_character ("\343\200\202", 3);
161 /* U+1D13D MUSICAL SYMBOL QUARTER REST */
162 is
= for_character ("\360\235\204\275", 4);
164 /* U+E0020 TAG SPACE */
165 is
= for_character ("\363\240\200\240", 4);
171 /* Locale encoding is GB18030. */
173 #if defined __GLIBC__
174 /* U+00A0 NO-BREAK SPACE */
175 is
= for_character ("\201\060\204\062", 4);
178 /* U+00B7 MIDDLE DOT */
179 is
= for_character ("\241\244", 2);
181 #if defined __GLIBC__
182 /* U+202F NARROW NO-BREAK SPACE */
183 is
= for_character ("\201\066\247\062", 4);
186 /* U+3002 IDEOGRAPHIC FULL STOP */
187 is
= for_character ("\241\243", 2);
189 /* U+1D13D MUSICAL SYMBOL QUARTER REST */
190 is
= for_character ("\224\062\301\065", 4);
192 /* U+E0020 TAG SPACE */
193 is
= for_character ("\323\066\231\060", 4);