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