1 /* Test of iswpunct() function.
2 Copyright (C) 2020-2024 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 (iswpunct
, int, (wint_t));
31 /* Returns the value of iswpunct 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
= (wchar_t) 0xBADFACE;
41 ret
= mbrtowc (&wc
, s
, n
, &state
);
49 main (int argc
, char *argv
[])
54 /* configure should already have checked that the locale is supported. */
55 if (setlocale (LC_ALL
, "") == NULL
)
62 /* Test single-byte characters.
64 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
65 no explicit list of punctuation or symbol characters. */
69 for (c
= 0; c
< 0x100; c
++)
72 case '\t': case '\v': case '\f':
73 case ' ': case '!': case '"': case '#': case '%':
74 case '&': case '\'': case '(': case ')': case '*':
75 case '+': case ',': case '-': case '.': case '/':
76 case '0': case '1': case '2': case '3': case '4':
77 case '5': case '6': case '7': case '8': case '9':
78 case ':': case ';': case '<': case '=': case '>':
80 case 'A': case 'B': case 'C': case 'D': case 'E':
81 case 'F': case 'G': case 'H': case 'I': case 'J':
82 case 'K': case 'L': case 'M': case 'N': case 'O':
83 case 'P': case 'Q': case 'R': case 'S': case 'T':
84 case 'U': case 'V': case 'W': case 'X': case 'Y':
86 case '[': case '\\': case ']': case '^': case '_':
87 case 'a': case 'b': case 'c': case 'd': case 'e':
88 case 'f': case 'g': case 'h': case 'i': case 'j':
89 case 'k': case 'l': case 'm': case 'n': case 'o':
90 case 'p': case 'q': case 'r': case 's': case 't':
91 case 'u': case 'v': case 'w': case 'x': case 'y':
92 case 'z': case '{': case '|': case '}': case '~':
93 /* c is in the ISO C "basic character set". */
94 buf
[0] = (unsigned char) c
;
95 is
= for_character (buf
, 1);
99 case '0': case '1': case '2': case '3': case '4':
100 case '5': case '6': case '7': case '8': case '9':
101 case 'A': case 'B': case 'C': case 'D': case 'E':
102 case 'F': case 'G': case 'H': case 'I': case 'J':
103 case 'K': case 'L': case 'M': case 'N': case 'O':
104 case 'P': case 'Q': case 'R': case 'S': case 'T':
105 case 'U': case 'V': case 'W': case 'X': case 'Y':
107 case 'a': case 'b': case 'c': case 'd': case 'e':
108 case 'f': case 'g': case 'h': case 'i': case 'j':
109 case 'k': case 'l': case 'm': case 'n': case 'o':
110 case 'p': case 'q': case 'r': case 's': case 't':
111 case 'u': case 'v': case 'w': case 'x': case 'y':
113 /* c is an alphanumeric or space character. */
116 case '!': case '"': case '#': case '%':
117 case '&': case '\'': case '(': case ')': case '*':
118 case '+': case ',': case '-': case '.': case '/':
119 case ':': case ';': case '<': case '=': case '>':
121 case '[': case '\\': case ']': case '^': case '_':
122 case '{': case '|': case '}': case '~':
123 /* These characters are usually expected to be punctuation or
124 symbol characters. */
139 /* C locale; tested above. */
140 /* These characters are not in the ISO C "basic character set", but
141 are nevertheless usually expected to be punctuation or symbol
143 is
= for_character ("$", 1);
145 is
= for_character ("@", 1);
147 is
= for_character ("`", 1);
149 return test_exit_status
;