1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
5 Copyright (C) 2006-2011 Free Software Foundation, Inc.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
21 /* Written by Bruno Haible and Paul Eggert. */
24 * ISO C 99 <wctype.h> for platforms that lack it.
25 * <http://www.opengroup.org/susv3xbd/wctype.h.html>
27 * iswctype, towctrans, towlower, towupper, wctrans, wctype,
28 * wctrans_t, and wctype_t are not yet implemented.
31 #ifndef _@GUARD_PREFIX@_WCTYPE_H
34 @PRAGMA_SYSTEM_HEADER@
39 /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
40 Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
42 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
43 included before <wchar.h>. */
50 /* Include the original <wctype.h> if it exists.
51 BeOS 5 has the functions but no <wctype.h>. */
52 /* The include_next requires a split double-inclusion guard. */
54 # @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
57 #ifndef _@GUARD_PREFIX@_WCTYPE_H
58 #define _@GUARD_PREFIX@_WCTYPE_H
60 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
62 /* The definition of _GL_WARN_ON_USE is copied here. */
64 /* Solaris 2.6 <wctype.h> includes <widec.h> which includes <euc.h> which
65 #defines a number of identifiers in the application namespace. Revert
77 /* Define wint_t and WEOF. (Also done in wchar.in.h.) */
78 #if !@HAVE_WINT_T@ && !defined wint_t
85 # define WEOF ((wint_t) -1)
90 #if !GNULIB_defined_wctype_functions
92 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
93 Linux libc5 has <wctype.h> and the functions but they are broken.
94 Assume all 11 functions (all isw* except iswblank) are implemented the
95 same way, or not at all. */
96 # if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
98 /* IRIX 5.3 has macros but no functions, its isw* macros refer to an
99 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
100 refer to system functions like _iswctype that are not in the
101 standard C library. Rather than try to get ancient buggy
102 implementations like this to work, just disable them. */
118 /* Linux libc5 has <wctype.h> and the functions but they are broken. */
119 # if @REPLACE_ISWCNTRL@
120 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
121 # define iswalnum rpl_iswalnum
122 # define iswalpha rpl_iswalpha
123 # define iswblank rpl_iswblank
124 # define iswcntrl rpl_iswcntrl
125 # define iswdigit rpl_iswdigit
126 # define iswgraph rpl_iswgraph
127 # define iswlower rpl_iswlower
128 # define iswprint rpl_iswprint
129 # define iswpunct rpl_iswpunct
130 # define iswspace rpl_iswspace
131 # define iswupper rpl_iswupper
132 # define iswxdigit rpl_iswxdigit
133 # define towlower rpl_towlower
134 # define towupper rpl_towupper
139 # if @REPLACE_ISWCNTRL@
146 return ((wc >= '0' && wc <= '9')
147 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
151 # if @REPLACE_ISWCNTRL@
158 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
162 # if @REPLACE_ISWCNTRL@
169 return wc == ' ' || wc == '\t';
173 # if @REPLACE_ISWCNTRL@
180 return (wc & ~0x1f) == 0 || wc == 0x7f;
184 # if @REPLACE_ISWCNTRL@
191 return wc >= '0' && wc <= '9';
195 # if @REPLACE_ISWCNTRL@
202 return wc >= '!' && wc <= '~';
206 # if @REPLACE_ISWCNTRL@
213 return wc >= 'a' && wc <= 'z';
217 # if @REPLACE_ISWCNTRL@
224 return wc >= ' ' && wc <= '~';
228 # if @REPLACE_ISWCNTRL@
235 return (wc >= '!' && wc <= '~'
236 && !((wc >= '0' && wc <= '9')
237 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
241 # if @REPLACE_ISWCNTRL@
248 return (wc == ' ' || wc == '\t'
249 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
253 # if @REPLACE_ISWCNTRL@
260 return wc >= 'A' && wc <= 'Z';
264 # if @REPLACE_ISWCNTRL@
271 return ((wc >= '0' && wc <= '9')
272 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
276 # if @REPLACE_ISWCNTRL@
283 return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
287 # if @REPLACE_ISWCNTRL@
294 return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
297 # elif @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@)
298 /* Only the iswblank function is missing. */
300 # if @REPLACE_ISWBLANK@
301 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
302 # define iswblank rpl_iswblank
304 _GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
306 _GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
311 # if defined __MINGW32__
313 /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
314 The functions towlower and towupper are implemented in the MSVCRT library
315 to take a wchar_t argument and return a wchar_t result. mingw declares
316 these functions to take a wint_t argument and return a wint_t result.
318 1. When the user passes an argument outside the range 0x0000..0xFFFF, the
319 function will look only at the lower 16 bits. This is allowed according
321 2. The return value is returned in the lower 16 bits of the result register.
322 The upper 16 bits are random: whatever happened to be in that part of the
323 result register. We need to fix this by adding a zero-extend from
324 wchar_t to wint_t after the call. */
327 rpl_towlower (wint_t wc)
329 return (wint_t) (wchar_t) towlower (wc);
331 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
332 # define towlower rpl_towlower
336 rpl_towupper (wint_t wc)
338 return (wint_t) (wchar_t) towupper (wc);
340 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
341 # define towupper rpl_towupper
344 # endif /* __MINGW32__ */
346 # define GNULIB_defined_wctype_functions 1
349 #if @REPLACE_ISWCNTRL@
350 _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
351 _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
352 _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
353 _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
354 _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
355 _GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
356 _GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
357 _GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
358 _GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
359 _GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
360 _GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
362 _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
363 _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
364 _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
365 _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
366 _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
367 _GL_CXXALIAS_SYS (iswlower, int, (wint_t wc));
368 _GL_CXXALIAS_SYS (iswprint, int, (wint_t wc));
369 _GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc));
370 _GL_CXXALIAS_SYS (iswspace, int, (wint_t wc));
371 _GL_CXXALIAS_SYS (iswupper, int, (wint_t wc));
372 _GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
374 _GL_CXXALIASWARN (iswalnum);
375 _GL_CXXALIASWARN (iswalpha);
376 _GL_CXXALIASWARN (iswcntrl);
377 _GL_CXXALIASWARN (iswdigit);
378 _GL_CXXALIASWARN (iswgraph);
379 _GL_CXXALIASWARN (iswlower);
380 _GL_CXXALIASWARN (iswprint);
381 _GL_CXXALIASWARN (iswpunct);
382 _GL_CXXALIASWARN (iswspace);
383 _GL_CXXALIASWARN (iswupper);
384 _GL_CXXALIASWARN (iswxdigit);
386 #if @GNULIB_ISWBLANK@
387 # if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@
388 _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
390 _GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
392 _GL_CXXALIASWARN (iswblank);
396 # if !GNULIB_defined_wctype_t
397 typedef void * wctype_t;
398 # define GNULIB_defined_wctype_t 1
402 /* Get a descriptor for a wide character property. */
404 # if !@HAVE_WCTYPE_T@
405 _GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name));
407 _GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
408 _GL_CXXALIASWARN (wctype);
409 #elif defined GNULIB_POSIXCHECK
411 # if HAVE_RAW_DECL_WCTYPE
412 _GL_WARN_ON_USE (wctype, "wctype is unportable - "
413 "use gnulib module wctype for portability");
417 /* Test whether a wide character has a given property.
418 The argument WC must be either a wchar_t value or WEOF.
419 The argument DESC must have been returned by the wctype() function. */
420 #if @GNULIB_ISWCTYPE@
421 # if !@HAVE_WCTYPE_T@
422 _GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc));
424 _GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
425 _GL_CXXALIASWARN (iswctype);
426 #elif defined GNULIB_POSIXCHECK
428 # if HAVE_RAW_DECL_ISWCTYPE
429 _GL_WARN_ON_USE (iswctype, "iswctype is unportable - "
430 "use gnulib module iswctype for portability");
434 #if @REPLACE_ISWCNTRL@ || defined __MINGW32__
435 _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
436 _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
438 _GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc));
439 _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
441 _GL_CXXALIASWARN (towlower);
442 _GL_CXXALIASWARN (towupper);
444 #if !@HAVE_WCTRANS_T@
445 # if !GNULIB_defined_wctrans_t
446 typedef void * wctrans_t;
447 # define GNULIB_defined_wctrans_t 1
451 /* Get a descriptor for a wide character case conversion. */
453 # if !@HAVE_WCTRANS_T@
454 _GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name));
456 _GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
457 _GL_CXXALIASWARN (wctrans);
458 #elif defined GNULIB_POSIXCHECK
460 # if HAVE_RAW_DECL_WCTRANS
461 _GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
462 "use gnulib module wctrans for portability");
466 /* Perform a given case conversion on a wide character.
467 The argument WC must be either a wchar_t value or WEOF.
468 The argument DESC must have been returned by the wctrans() function. */
469 #if @GNULIB_TOWCTRANS@
470 # if !@HAVE_WCTRANS_T@
471 _GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
473 _GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
474 _GL_CXXALIASWARN (towctrans);
475 #elif defined GNULIB_POSIXCHECK
477 # if HAVE_RAW_DECL_TOWCTRANS
478 _GL_WARN_ON_USE (towctrans, "towctrans is unportable - "
479 "use gnulib module towctrans for portability");
484 #endif /* _@GUARD_PREFIX@_WCTYPE_H */
485 #endif /* _@GUARD_PREFIX@_WCTYPE_H */