Commit | Line | Data |
---|---|---|
8690e634 JK |
1 | /* A substitute for ISO C99 <wctype.h>, for platforms that lack it. |
2 | ||
5df4cba6 | 3 | Copyright (C) 2006-2020 Free Software Foundation, Inc. |
8690e634 JK |
4 | |
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 3, or (at your option) | |
8 | any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
c0c3707f | 16 | along with this program; if not, see <https://www.gnu.org/licenses/>. */ |
8690e634 JK |
17 | |
18 | /* Written by Bruno Haible and Paul Eggert. */ | |
19 | ||
20 | /* | |
21 | * ISO C 99 <wctype.h> for platforms that lack it. | |
c0c3707f | 22 | * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wctype.h.html> |
8690e634 JK |
23 | * |
24 | * iswctype, towctrans, towlower, towupper, wctrans, wctype, | |
25 | * wctrans_t, and wctype_t are not yet implemented. | |
26 | */ | |
27 | ||
8690e634 JK |
28 | #if __GNUC__ >= 3 |
29 | @PRAGMA_SYSTEM_HEADER@ | |
30 | #endif | |
31 | @PRAGMA_COLUMNS@ | |
32 | ||
49e4877c PA |
33 | #if (defined __MINGW32__ && defined __CTYPE_H_SOURCED__) |
34 | ||
35 | /* Special invocation convention: | |
36 | - With MinGW 3.22, when <ctype.h> includes <wctype.h>, only some part of | |
37 | <wctype.h> is being processed, which doesn't include the idempotency | |
38 | guard. */ | |
39 | ||
40 | #@INCLUDE_NEXT@ @NEXT_WCTYPE_H@ | |
41 | ||
42 | #else | |
43 | /* Normal invocation convention. */ | |
44 | ||
45 | #ifndef _@GUARD_PREFIX@_WCTYPE_H | |
46 | ||
8690e634 JK |
47 | #if @HAVE_WINT_T@ |
48 | /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. | |
49 | Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | |
50 | <wchar.h>. | |
51 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | |
52 | included before <wchar.h>. */ | |
53 | # include <stddef.h> | |
54 | # include <stdio.h> | |
55 | # include <time.h> | |
56 | # include <wchar.h> | |
57 | #endif | |
58 | ||
c0c3707f CB |
59 | /* Native Windows (mingw, MSVC) have declarations of towupper, towlower, and |
60 | isw* functions in <ctype.h>, <wchar.h> as well as in <wctype.h>. Include | |
61 | <ctype.h>, <wchar.h> in advance to avoid rpl_ prefix being added to the | |
62 | declarations. */ | |
63 | #if defined _WIN32 && ! defined __CYGWIN__ | |
4a626d0a | 64 | # include <ctype.h> |
c0c3707f | 65 | # include <wchar.h> |
4a626d0a PA |
66 | #endif |
67 | ||
8690e634 JK |
68 | /* Include the original <wctype.h> if it exists. |
69 | BeOS 5 has the functions but no <wctype.h>. */ | |
70 | /* The include_next requires a split double-inclusion guard. */ | |
71 | #if @HAVE_WCTYPE_H@ | |
72 | # @INCLUDE_NEXT@ @NEXT_WCTYPE_H@ | |
73 | #endif | |
74 | ||
75 | #ifndef _@GUARD_PREFIX@_WCTYPE_H | |
76 | #define _@GUARD_PREFIX@_WCTYPE_H | |
77 | ||
4a626d0a PA |
78 | #ifndef _GL_INLINE_HEADER_BEGIN |
79 | #error "Please include config.h first." | |
80 | #endif | |
a512b375 JB |
81 | _GL_INLINE_HEADER_BEGIN |
82 | #ifndef _GL_WCTYPE_INLINE | |
83 | # define _GL_WCTYPE_INLINE _GL_INLINE | |
84 | #endif | |
85 | ||
8690e634 JK |
86 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
87 | ||
88 | /* The definition of _GL_WARN_ON_USE is copied here. */ | |
89 | ||
90 | /* Solaris 2.6 <wctype.h> includes <widec.h> which includes <euc.h> which | |
91 | #defines a number of identifiers in the application namespace. Revert | |
92 | these #defines. */ | |
93 | #ifdef __sun | |
94 | # undef multibyte | |
95 | # undef eucw1 | |
96 | # undef eucw2 | |
97 | # undef eucw3 | |
98 | # undef scrw1 | |
99 | # undef scrw2 | |
100 | # undef scrw3 | |
101 | #endif | |
102 | ||
103 | /* Define wint_t and WEOF. (Also done in wchar.in.h.) */ | |
104 | #if !@HAVE_WINT_T@ && !defined wint_t | |
105 | # define wint_t int | |
106 | # ifndef WEOF | |
107 | # define WEOF -1 | |
108 | # endif | |
109 | #else | |
c0c3707f CB |
110 | /* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or |
111 | <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that | |
112 | wint_t must be "unchanged by default argument promotions". Override it. */ | |
113 | # if @GNULIB_OVERRIDES_WINT_T@ | |
8690e634 | 114 | # if !GNULIB_defined_wint_t |
c0c3707f CB |
115 | # if @HAVE_CRTDEFS_H@ |
116 | # include <crtdefs.h> | |
117 | # else | |
118 | # include <stddef.h> | |
119 | # endif | |
8690e634 JK |
120 | typedef unsigned int rpl_wint_t; |
121 | # undef wint_t | |
122 | # define wint_t rpl_wint_t | |
123 | # define GNULIB_defined_wint_t 1 | |
124 | # endif | |
125 | # endif | |
126 | # ifndef WEOF | |
127 | # define WEOF ((wint_t) -1) | |
128 | # endif | |
129 | #endif | |
130 | ||
131 | ||
132 | #if !GNULIB_defined_wctype_functions | |
133 | ||
134 | /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions. | |
135 | Linux libc5 has <wctype.h> and the functions but they are broken. | |
c0c3707f CB |
136 | mingw and MSVC have <wctype.h> and the functions but they take a wchar_t |
137 | as argument, not an rpl_wint_t. | |
8690e634 JK |
138 | Assume all 11 functions (all isw* except iswblank) are implemented the |
139 | same way, or not at all. */ | |
140 | # if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ | |
141 | ||
c0c3707f CB |
142 | # if @GNULIB_OVERRIDES_WINT_T@ /* implies @REPLACE_ISWCNTRL@ */ |
143 | ||
144 | _GL_WCTYPE_INLINE int | |
145 | rpl_iswalnum (wint_t wc) | |
146 | { | |
147 | return ((wchar_t) wc == wc ? iswalnum ((wchar_t) wc) : 0); | |
148 | } | |
149 | ||
150 | _GL_WCTYPE_INLINE int | |
151 | rpl_iswalpha (wint_t wc) | |
152 | { | |
153 | return ((wchar_t) wc == wc ? iswalpha ((wchar_t) wc) : 0); | |
154 | } | |
155 | ||
156 | _GL_WCTYPE_INLINE int | |
157 | rpl_iswblank (wint_t wc) | |
158 | { | |
159 | return ((wchar_t) wc == wc ? iswblank ((wchar_t) wc) : 0); | |
160 | } | |
161 | ||
162 | _GL_WCTYPE_INLINE int | |
163 | rpl_iswcntrl (wint_t wc) | |
164 | { | |
165 | return ((wchar_t) wc == wc ? iswcntrl ((wchar_t) wc) : 0); | |
166 | } | |
167 | ||
168 | _GL_WCTYPE_INLINE int | |
169 | rpl_iswdigit (wint_t wc) | |
170 | { | |
5df4cba6 | 171 | return ((wchar_t) wc == wc ? wc >= '0' && wc <= '9' : 0); |
c0c3707f CB |
172 | } |
173 | ||
174 | _GL_WCTYPE_INLINE int | |
175 | rpl_iswgraph (wint_t wc) | |
176 | { | |
177 | return ((wchar_t) wc == wc ? iswgraph ((wchar_t) wc) : 0); | |
178 | } | |
179 | ||
180 | _GL_WCTYPE_INLINE int | |
181 | rpl_iswlower (wint_t wc) | |
182 | { | |
183 | return ((wchar_t) wc == wc ? iswlower ((wchar_t) wc) : 0); | |
184 | } | |
185 | ||
186 | _GL_WCTYPE_INLINE int | |
187 | rpl_iswprint (wint_t wc) | |
188 | { | |
189 | return ((wchar_t) wc == wc ? iswprint ((wchar_t) wc) : 0); | |
190 | } | |
191 | ||
192 | _GL_WCTYPE_INLINE int | |
193 | rpl_iswpunct (wint_t wc) | |
194 | { | |
195 | return ((wchar_t) wc == wc ? iswpunct ((wchar_t) wc) : 0); | |
196 | } | |
197 | ||
198 | _GL_WCTYPE_INLINE int | |
199 | rpl_iswspace (wint_t wc) | |
200 | { | |
201 | return ((wchar_t) wc == wc ? iswspace ((wchar_t) wc) : 0); | |
202 | } | |
203 | ||
204 | _GL_WCTYPE_INLINE int | |
205 | rpl_iswupper (wint_t wc) | |
206 | { | |
207 | return ((wchar_t) wc == wc ? iswupper ((wchar_t) wc) : 0); | |
208 | } | |
209 | ||
210 | _GL_WCTYPE_INLINE int | |
211 | rpl_iswxdigit (wint_t wc) | |
212 | { | |
5df4cba6 SM |
213 | return ((wchar_t) wc == wc |
214 | ? (wc >= '0' && wc <= '9') | |
215 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F') | |
216 | : 0); | |
c0c3707f CB |
217 | } |
218 | ||
219 | _GL_WCTYPE_INLINE wint_t | |
220 | rpl_towlower (wint_t wc) | |
221 | { | |
222 | return ((wchar_t) wc == wc ? (wchar_t) towlower ((wchar_t) wc) : wc); | |
223 | } | |
224 | ||
225 | _GL_WCTYPE_INLINE wint_t | |
226 | rpl_towupper (wint_t wc) | |
227 | { | |
228 | return ((wchar_t) wc == wc ? (wchar_t) towupper ((wchar_t) wc) : wc); | |
229 | } | |
8690e634 | 230 | |
8690e634 | 231 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
c0c3707f CB |
232 | # undef iswalnum |
233 | # undef iswalpha | |
234 | # undef iswblank | |
235 | # undef iswcntrl | |
236 | # undef iswdigit | |
237 | # undef iswgraph | |
238 | # undef iswlower | |
239 | # undef iswprint | |
240 | # undef iswpunct | |
241 | # undef iswspace | |
242 | # undef iswupper | |
243 | # undef iswxdigit | |
244 | # undef towlower | |
245 | # undef towupper | |
8690e634 JK |
246 | # define iswalnum rpl_iswalnum |
247 | # define iswalpha rpl_iswalpha | |
248 | # define iswblank rpl_iswblank | |
249 | # define iswcntrl rpl_iswcntrl | |
250 | # define iswdigit rpl_iswdigit | |
251 | # define iswgraph rpl_iswgraph | |
252 | # define iswlower rpl_iswlower | |
253 | # define iswprint rpl_iswprint | |
254 | # define iswpunct rpl_iswpunct | |
255 | # define iswspace rpl_iswspace | |
256 | # define iswupper rpl_iswupper | |
257 | # define iswxdigit rpl_iswxdigit | |
8690e634 JK |
258 | # define towlower rpl_towlower |
259 | # define towupper rpl_towupper | |
260 | # endif | |
c0c3707f CB |
261 | |
262 | # else | |
263 | ||
264 | /* IRIX 5.3 has macros but no functions, its isw* macros refer to an | |
265 | undefined variable _ctmp_ and to <ctype.h> macros like _P, and they | |
266 | refer to system functions like _iswctype that are not in the | |
267 | standard C library. Rather than try to get ancient buggy | |
268 | implementations like this to work, just disable them. */ | |
269 | # undef iswalnum | |
270 | # undef iswalpha | |
271 | # undef iswblank | |
272 | # undef iswcntrl | |
273 | # undef iswdigit | |
274 | # undef iswgraph | |
275 | # undef iswlower | |
276 | # undef iswprint | |
277 | # undef iswpunct | |
278 | # undef iswspace | |
279 | # undef iswupper | |
280 | # undef iswxdigit | |
281 | # undef towlower | |
282 | # undef towupper | |
283 | ||
284 | /* Linux libc5 has <wctype.h> and the functions but they are broken. */ | |
285 | # if @REPLACE_ISWCNTRL@ | |
286 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
287 | # define iswalnum rpl_iswalnum | |
288 | # define iswalpha rpl_iswalpha | |
289 | # define iswblank rpl_iswblank | |
290 | # define iswcntrl rpl_iswcntrl | |
291 | # define iswdigit rpl_iswdigit | |
292 | # define iswgraph rpl_iswgraph | |
293 | # define iswlower rpl_iswlower | |
294 | # define iswprint rpl_iswprint | |
295 | # define iswpunct rpl_iswpunct | |
296 | # define iswspace rpl_iswspace | |
297 | # define iswupper rpl_iswupper | |
298 | # define iswxdigit rpl_iswxdigit | |
299 | # endif | |
300 | # endif | |
301 | # if @REPLACE_TOWLOWER@ | |
302 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
303 | # define towlower rpl_towlower | |
304 | # define towupper rpl_towupper | |
305 | # endif | |
306 | # endif | |
8690e634 | 307 | |
a512b375 | 308 | _GL_WCTYPE_INLINE int |
c0c3707f | 309 | # if @REPLACE_ISWCNTRL@ |
8690e634 | 310 | rpl_iswalnum |
c0c3707f | 311 | # else |
8690e634 | 312 | iswalnum |
c0c3707f | 313 | # endif |
8690e634 JK |
314 | (wint_t wc) |
315 | { | |
316 | return ((wc >= '0' && wc <= '9') | |
317 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); | |
318 | } | |
319 | ||
a512b375 | 320 | _GL_WCTYPE_INLINE int |
c0c3707f | 321 | # if @REPLACE_ISWCNTRL@ |
8690e634 | 322 | rpl_iswalpha |
c0c3707f | 323 | # else |
8690e634 | 324 | iswalpha |
c0c3707f | 325 | # endif |
8690e634 JK |
326 | (wint_t wc) |
327 | { | |
328 | return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; | |
329 | } | |
330 | ||
a512b375 | 331 | _GL_WCTYPE_INLINE int |
c0c3707f | 332 | # if @REPLACE_ISWCNTRL@ |
8690e634 | 333 | rpl_iswblank |
c0c3707f | 334 | # else |
8690e634 | 335 | iswblank |
c0c3707f | 336 | # endif |
8690e634 JK |
337 | (wint_t wc) |
338 | { | |
339 | return wc == ' ' || wc == '\t'; | |
340 | } | |
341 | ||
a512b375 | 342 | _GL_WCTYPE_INLINE int |
c0c3707f | 343 | # if @REPLACE_ISWCNTRL@ |
8690e634 | 344 | rpl_iswcntrl |
c0c3707f | 345 | # else |
8690e634 | 346 | iswcntrl |
c0c3707f | 347 | # endif |
8690e634 JK |
348 | (wint_t wc) |
349 | { | |
350 | return (wc & ~0x1f) == 0 || wc == 0x7f; | |
351 | } | |
352 | ||
a512b375 | 353 | _GL_WCTYPE_INLINE int |
5df4cba6 | 354 | # if @REPLACE_ISWDIGIT@ |
8690e634 | 355 | rpl_iswdigit |
c0c3707f | 356 | # else |
8690e634 | 357 | iswdigit |
c0c3707f | 358 | # endif |
8690e634 JK |
359 | (wint_t wc) |
360 | { | |
361 | return wc >= '0' && wc <= '9'; | |
362 | } | |
363 | ||
a512b375 | 364 | _GL_WCTYPE_INLINE int |
c0c3707f | 365 | # if @REPLACE_ISWCNTRL@ |
8690e634 | 366 | rpl_iswgraph |
c0c3707f | 367 | # else |
8690e634 | 368 | iswgraph |
c0c3707f | 369 | # endif |
8690e634 JK |
370 | (wint_t wc) |
371 | { | |
372 | return wc >= '!' && wc <= '~'; | |
373 | } | |
374 | ||
a512b375 | 375 | _GL_WCTYPE_INLINE int |
c0c3707f | 376 | # if @REPLACE_ISWCNTRL@ |
8690e634 | 377 | rpl_iswlower |
c0c3707f | 378 | # else |
8690e634 | 379 | iswlower |
c0c3707f | 380 | # endif |
8690e634 JK |
381 | (wint_t wc) |
382 | { | |
383 | return wc >= 'a' && wc <= 'z'; | |
384 | } | |
385 | ||
a512b375 | 386 | _GL_WCTYPE_INLINE int |
c0c3707f | 387 | # if @REPLACE_ISWCNTRL@ |
8690e634 | 388 | rpl_iswprint |
c0c3707f | 389 | # else |
8690e634 | 390 | iswprint |
c0c3707f | 391 | # endif |
8690e634 JK |
392 | (wint_t wc) |
393 | { | |
394 | return wc >= ' ' && wc <= '~'; | |
395 | } | |
396 | ||
a512b375 | 397 | _GL_WCTYPE_INLINE int |
c0c3707f | 398 | # if @REPLACE_ISWCNTRL@ |
8690e634 | 399 | rpl_iswpunct |
c0c3707f | 400 | # else |
8690e634 | 401 | iswpunct |
c0c3707f | 402 | # endif |
8690e634 JK |
403 | (wint_t wc) |
404 | { | |
405 | return (wc >= '!' && wc <= '~' | |
406 | && !((wc >= '0' && wc <= '9') | |
407 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))); | |
408 | } | |
409 | ||
a512b375 | 410 | _GL_WCTYPE_INLINE int |
c0c3707f | 411 | # if @REPLACE_ISWCNTRL@ |
8690e634 | 412 | rpl_iswspace |
c0c3707f | 413 | # else |
8690e634 | 414 | iswspace |
c0c3707f | 415 | # endif |
8690e634 JK |
416 | (wint_t wc) |
417 | { | |
418 | return (wc == ' ' || wc == '\t' | |
419 | || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); | |
420 | } | |
421 | ||
a512b375 | 422 | _GL_WCTYPE_INLINE int |
c0c3707f | 423 | # if @REPLACE_ISWCNTRL@ |
8690e634 | 424 | rpl_iswupper |
c0c3707f | 425 | # else |
8690e634 | 426 | iswupper |
c0c3707f | 427 | # endif |
8690e634 JK |
428 | (wint_t wc) |
429 | { | |
430 | return wc >= 'A' && wc <= 'Z'; | |
431 | } | |
432 | ||
a512b375 | 433 | _GL_WCTYPE_INLINE int |
5df4cba6 | 434 | # if @REPLACE_ISWXDIGIT@ |
8690e634 | 435 | rpl_iswxdigit |
c0c3707f | 436 | # else |
8690e634 | 437 | iswxdigit |
c0c3707f | 438 | # endif |
8690e634 JK |
439 | (wint_t wc) |
440 | { | |
441 | return ((wc >= '0' && wc <= '9') | |
442 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); | |
443 | } | |
444 | ||
a512b375 | 445 | _GL_WCTYPE_INLINE wint_t |
c0c3707f | 446 | # if @REPLACE_TOWLOWER@ |
8690e634 | 447 | rpl_towlower |
c0c3707f | 448 | # else |
8690e634 | 449 | towlower |
c0c3707f | 450 | # endif |
8690e634 JK |
451 | (wint_t wc) |
452 | { | |
453 | return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc); | |
454 | } | |
455 | ||
a512b375 | 456 | _GL_WCTYPE_INLINE wint_t |
c0c3707f | 457 | # if @REPLACE_TOWLOWER@ |
8690e634 | 458 | rpl_towupper |
c0c3707f | 459 | # else |
8690e634 | 460 | towupper |
c0c3707f | 461 | # endif |
8690e634 JK |
462 | (wint_t wc) |
463 | { | |
464 | return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); | |
465 | } | |
466 | ||
c0c3707f CB |
467 | # endif |
468 | ||
5df4cba6 SM |
469 | # else |
470 | /* Only some of the functions are missing or broken. */ | |
8690e634 | 471 | |
5df4cba6 SM |
472 | # if @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@) |
473 | /* Only the iswblank function is missing. */ | |
474 | # if @REPLACE_ISWBLANK@ | |
475 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
476 | # define iswblank rpl_iswblank | |
477 | # endif | |
8690e634 | 478 | _GL_FUNCDECL_RPL (iswblank, int, (wint_t wc)); |
5df4cba6 | 479 | # else |
8690e634 | 480 | _GL_FUNCDECL_SYS (iswblank, int, (wint_t wc)); |
5df4cba6 SM |
481 | # endif |
482 | # endif | |
483 | ||
484 | # if @GNULIB_ISWDIGIT@ | |
485 | # if @REPLACE_ISWDIGIT@ | |
486 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
487 | # undef iswdigit | |
488 | # define iswdigit rpl_iswdigit | |
489 | # endif | |
490 | _GL_FUNCDECL_RPL (iswdigit, int, (wint_t wc)); | |
491 | # endif | |
492 | # endif | |
493 | ||
494 | # if @GNULIB_ISWXDIGIT@ | |
495 | # if @REPLACE_ISWXDIGIT@ | |
496 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
497 | # undef iswxdigit | |
498 | # define iswxdigit rpl_iswxdigit | |
499 | # endif | |
500 | _GL_FUNCDECL_RPL (iswxdigit, int, (wint_t wc)); | |
501 | # endif | |
8690e634 JK |
502 | # endif |
503 | ||
504 | # endif | |
505 | ||
c0c3707f | 506 | # if defined __MINGW32__ && !@GNULIB_OVERRIDES_WINT_T@ |
8690e634 JK |
507 | |
508 | /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t. | |
509 | The functions towlower and towupper are implemented in the MSVCRT library | |
510 | to take a wchar_t argument and return a wchar_t result. mingw declares | |
511 | these functions to take a wint_t argument and return a wint_t result. | |
512 | This means that: | |
513 | 1. When the user passes an argument outside the range 0x0000..0xFFFF, the | |
514 | function will look only at the lower 16 bits. This is allowed according | |
515 | to POSIX. | |
516 | 2. The return value is returned in the lower 16 bits of the result register. | |
517 | The upper 16 bits are random: whatever happened to be in that part of the | |
518 | result register. We need to fix this by adding a zero-extend from | |
519 | wchar_t to wint_t after the call. */ | |
520 | ||
a512b375 | 521 | _GL_WCTYPE_INLINE wint_t |
8690e634 JK |
522 | rpl_towlower (wint_t wc) |
523 | { | |
524 | return (wint_t) (wchar_t) towlower (wc); | |
525 | } | |
526 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
527 | # define towlower rpl_towlower | |
528 | # endif | |
529 | ||
a512b375 | 530 | _GL_WCTYPE_INLINE wint_t |
8690e634 JK |
531 | rpl_towupper (wint_t wc) |
532 | { | |
533 | return (wint_t) (wchar_t) towupper (wc); | |
534 | } | |
535 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
536 | # define towupper rpl_towupper | |
537 | # endif | |
538 | ||
c0c3707f | 539 | # endif /* __MINGW32__ && !@GNULIB_OVERRIDES_WINT_T@ */ |
8690e634 JK |
540 | |
541 | # define GNULIB_defined_wctype_functions 1 | |
542 | #endif | |
543 | ||
544 | #if @REPLACE_ISWCNTRL@ | |
545 | _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc)); | |
8690e634 JK |
546 | #else |
547 | _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc)); | |
5df4cba6 SM |
548 | #endif |
549 | #if @REPLACE_ISWCNTRL@ | |
550 | _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc)); | |
551 | #else | |
8690e634 | 552 | _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc)); |
5df4cba6 SM |
553 | #endif |
554 | #if @REPLACE_ISWCNTRL@ | |
555 | _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc)); | |
556 | #else | |
8690e634 | 557 | _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc)); |
5df4cba6 SM |
558 | #endif |
559 | #if @GNULIB_ISWDIGIT@ | |
560 | # if @REPLACE_ISWDIGIT@ | |
561 | _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc)); | |
562 | # else | |
8690e634 | 563 | _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc)); |
5df4cba6 SM |
564 | # endif |
565 | #endif | |
566 | #if @REPLACE_ISWCNTRL@ | |
567 | _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc)); | |
568 | #else | |
8690e634 | 569 | _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc)); |
5df4cba6 SM |
570 | #endif |
571 | #if @REPLACE_ISWCNTRL@ | |
572 | _GL_CXXALIAS_RPL (iswlower, int, (wint_t wc)); | |
573 | #else | |
8690e634 | 574 | _GL_CXXALIAS_SYS (iswlower, int, (wint_t wc)); |
5df4cba6 SM |
575 | #endif |
576 | #if @REPLACE_ISWCNTRL@ | |
577 | _GL_CXXALIAS_RPL (iswprint, int, (wint_t wc)); | |
578 | #else | |
8690e634 | 579 | _GL_CXXALIAS_SYS (iswprint, int, (wint_t wc)); |
5df4cba6 SM |
580 | #endif |
581 | #if @REPLACE_ISWCNTRL@ | |
582 | _GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc)); | |
583 | #else | |
8690e634 | 584 | _GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc)); |
5df4cba6 SM |
585 | #endif |
586 | #if @REPLACE_ISWCNTRL@ | |
587 | _GL_CXXALIAS_RPL (iswspace, int, (wint_t wc)); | |
588 | #else | |
8690e634 | 589 | _GL_CXXALIAS_SYS (iswspace, int, (wint_t wc)); |
5df4cba6 SM |
590 | #endif |
591 | #if @REPLACE_ISWCNTRL@ | |
592 | _GL_CXXALIAS_RPL (iswupper, int, (wint_t wc)); | |
593 | #else | |
8690e634 | 594 | _GL_CXXALIAS_SYS (iswupper, int, (wint_t wc)); |
5df4cba6 SM |
595 | #endif |
596 | #if @GNULIB_ISWXDIGIT@ | |
597 | # if @REPLACE_ISWXDIGIT@ | |
598 | _GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc)); | |
599 | # else | |
8690e634 | 600 | _GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc)); |
5df4cba6 | 601 | # endif |
8690e634 | 602 | #endif |
c0c3707f | 603 | #if __GLIBC__ >= 2 |
8690e634 JK |
604 | _GL_CXXALIASWARN (iswalnum); |
605 | _GL_CXXALIASWARN (iswalpha); | |
606 | _GL_CXXALIASWARN (iswcntrl); | |
607 | _GL_CXXALIASWARN (iswdigit); | |
608 | _GL_CXXALIASWARN (iswgraph); | |
609 | _GL_CXXALIASWARN (iswlower); | |
610 | _GL_CXXALIASWARN (iswprint); | |
611 | _GL_CXXALIASWARN (iswpunct); | |
612 | _GL_CXXALIASWARN (iswspace); | |
613 | _GL_CXXALIASWARN (iswupper); | |
614 | _GL_CXXALIASWARN (iswxdigit); | |
c0c3707f | 615 | #endif |
8690e634 JK |
616 | |
617 | #if @GNULIB_ISWBLANK@ | |
618 | # if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@ | |
619 | _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc)); | |
620 | # else | |
621 | _GL_CXXALIAS_SYS (iswblank, int, (wint_t wc)); | |
622 | # endif | |
c0c3707f | 623 | # if __GLIBC__ >= 2 |
8690e634 | 624 | _GL_CXXALIASWARN (iswblank); |
c0c3707f | 625 | # endif |
8690e634 JK |
626 | #endif |
627 | ||
628 | #if !@HAVE_WCTYPE_T@ | |
629 | # if !GNULIB_defined_wctype_t | |
630 | typedef void * wctype_t; | |
631 | # define GNULIB_defined_wctype_t 1 | |
632 | # endif | |
633 | #endif | |
634 | ||
635 | /* Get a descriptor for a wide character property. */ | |
636 | #if @GNULIB_WCTYPE@ | |
637 | # if !@HAVE_WCTYPE_T@ | |
638 | _GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name)); | |
639 | # endif | |
640 | _GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name)); | |
c0c3707f | 641 | # if __GLIBC__ >= 2 |
8690e634 | 642 | _GL_CXXALIASWARN (wctype); |
c0c3707f | 643 | # endif |
8690e634 JK |
644 | #elif defined GNULIB_POSIXCHECK |
645 | # undef wctype | |
646 | # if HAVE_RAW_DECL_WCTYPE | |
647 | _GL_WARN_ON_USE (wctype, "wctype is unportable - " | |
648 | "use gnulib module wctype for portability"); | |
649 | # endif | |
650 | #endif | |
651 | ||
652 | /* Test whether a wide character has a given property. | |
653 | The argument WC must be either a wchar_t value or WEOF. | |
654 | The argument DESC must have been returned by the wctype() function. */ | |
655 | #if @GNULIB_ISWCTYPE@ | |
c0c3707f CB |
656 | # if @GNULIB_OVERRIDES_WINT_T@ |
657 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
658 | # undef iswctype | |
659 | # define iswctype rpl_iswctype | |
660 | # endif | |
661 | _GL_FUNCDECL_RPL (iswctype, int, (wint_t wc, wctype_t desc)); | |
662 | _GL_CXXALIAS_RPL (iswctype, int, (wint_t wc, wctype_t desc)); | |
663 | # else | |
664 | # if !@HAVE_WCTYPE_T@ | |
8690e634 | 665 | _GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc)); |
c0c3707f | 666 | # endif |
8690e634 | 667 | _GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc)); |
c0c3707f CB |
668 | # endif |
669 | # if __GLIBC__ >= 2 | |
8690e634 | 670 | _GL_CXXALIASWARN (iswctype); |
c0c3707f | 671 | # endif |
8690e634 JK |
672 | #elif defined GNULIB_POSIXCHECK |
673 | # undef iswctype | |
674 | # if HAVE_RAW_DECL_ISWCTYPE | |
675 | _GL_WARN_ON_USE (iswctype, "iswctype is unportable - " | |
676 | "use gnulib module iswctype for portability"); | |
677 | # endif | |
678 | #endif | |
679 | ||
680 | #if @REPLACE_TOWLOWER@ || defined __MINGW32__ | |
681 | _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc)); | |
682 | _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc)); | |
683 | #else | |
684 | _GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc)); | |
685 | _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc)); | |
686 | #endif | |
c0c3707f | 687 | #if __GLIBC__ >= 2 |
8690e634 JK |
688 | _GL_CXXALIASWARN (towlower); |
689 | _GL_CXXALIASWARN (towupper); | |
c0c3707f | 690 | #endif |
8690e634 JK |
691 | |
692 | #if !@HAVE_WCTRANS_T@ | |
693 | # if !GNULIB_defined_wctrans_t | |
694 | typedef void * wctrans_t; | |
695 | # define GNULIB_defined_wctrans_t 1 | |
696 | # endif | |
697 | #endif | |
698 | ||
699 | /* Get a descriptor for a wide character case conversion. */ | |
700 | #if @GNULIB_WCTRANS@ | |
701 | # if !@HAVE_WCTRANS_T@ | |
702 | _GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name)); | |
703 | # endif | |
704 | _GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name)); | |
c0c3707f | 705 | # if __GLIBC__ >= 2 |
8690e634 | 706 | _GL_CXXALIASWARN (wctrans); |
c0c3707f | 707 | # endif |
8690e634 JK |
708 | #elif defined GNULIB_POSIXCHECK |
709 | # undef wctrans | |
710 | # if HAVE_RAW_DECL_WCTRANS | |
711 | _GL_WARN_ON_USE (wctrans, "wctrans is unportable - " | |
712 | "use gnulib module wctrans for portability"); | |
713 | # endif | |
714 | #endif | |
715 | ||
716 | /* Perform a given case conversion on a wide character. | |
717 | The argument WC must be either a wchar_t value or WEOF. | |
718 | The argument DESC must have been returned by the wctrans() function. */ | |
719 | #if @GNULIB_TOWCTRANS@ | |
720 | # if !@HAVE_WCTRANS_T@ | |
721 | _GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); | |
722 | # endif | |
723 | _GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); | |
c0c3707f | 724 | # if __GLIBC__ >= 2 |
8690e634 | 725 | _GL_CXXALIASWARN (towctrans); |
c0c3707f | 726 | # endif |
8690e634 JK |
727 | #elif defined GNULIB_POSIXCHECK |
728 | # undef towctrans | |
729 | # if HAVE_RAW_DECL_TOWCTRANS | |
730 | _GL_WARN_ON_USE (towctrans, "towctrans is unportable - " | |
731 | "use gnulib module towctrans for portability"); | |
732 | # endif | |
733 | #endif | |
734 | ||
a512b375 | 735 | _GL_INLINE_HEADER_END |
8690e634 JK |
736 | |
737 | #endif /* _@GUARD_PREFIX@_WCTYPE_H */ | |
738 | #endif /* _@GUARD_PREFIX@_WCTYPE_H */ | |
49e4877c | 739 | #endif |