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.
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@
60 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
62 /* The definition of _GL_WARN_ON_USE is copied here. */
64 /* Define wint_t and WEOF. (Also done in wchar.in.h.) */
65 #if !@HAVE_WINT_T@ && !defined wint_t
72 # define WEOF ((wint_t) -1)
77 #if !GNULIB_defined_wctype_functions
79 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
80 Linux libc5 has <wctype.h> and the functions but they are broken.
81 Assume all 11 functions (all isw* except iswblank) are implemented the
82 same way, or not at all. */
83 # if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
85 /* IRIX 5.3 has macros but no functions, its isw* macros refer to an
86 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
87 refer to system functions like _iswctype that are not in the
88 standard C library. Rather than try to get ancient buggy
89 implementations like this to work, just disable them. */
105 /* Linux libc5 has <wctype.h> and the functions but they are broken. */
106 # if @REPLACE_ISWCNTRL@
107 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
108 # define iswalnum rpl_iswalnum
109 # define iswalpha rpl_iswalpha
110 # define iswblank rpl_iswblank
111 # define iswcntrl rpl_iswcntrl
112 # define iswdigit rpl_iswdigit
113 # define iswgraph rpl_iswgraph
114 # define iswlower rpl_iswlower
115 # define iswprint rpl_iswprint
116 # define iswpunct rpl_iswpunct
117 # define iswspace rpl_iswspace
118 # define iswupper rpl_iswupper
119 # define iswxdigit rpl_iswxdigit
120 # define towlower rpl_towlower
121 # define towupper rpl_towupper
126 # if @REPLACE_ISWCNTRL@
133 return ((wc >= '0' && wc <= '9')
134 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
138 # if @REPLACE_ISWCNTRL@
145 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
149 # if @REPLACE_ISWCNTRL@
156 return wc == ' ' || wc == '\t';
160 # if @REPLACE_ISWCNTRL@
167 return (wc & ~0x1f) == 0 || wc == 0x7f;
171 # if @REPLACE_ISWCNTRL@
178 return wc >= '0' && wc <= '9';
182 # if @REPLACE_ISWCNTRL@
189 return wc >= '!' && wc <= '~';
193 # if @REPLACE_ISWCNTRL@
200 return wc >= 'a' && wc <= 'z';
204 # if @REPLACE_ISWCNTRL@
211 return wc >= ' ' && wc <= '~';
215 # if @REPLACE_ISWCNTRL@
222 return (wc >= '!' && wc <= '~'
223 && !((wc >= '0' && wc <= '9')
224 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
228 # if @REPLACE_ISWCNTRL@
235 return (wc == ' ' || wc == '\t'
236 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
240 # if @REPLACE_ISWCNTRL@
247 return wc >= 'A' && wc <= 'Z';
251 # if @REPLACE_ISWCNTRL@
258 return ((wc >= '0' && wc <= '9')
259 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
263 # if @REPLACE_ISWCNTRL@
270 return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
274 # if @REPLACE_ISWCNTRL@
281 return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
284 # elif @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@)
285 /* Only the iswblank function is missing. */
287 # if @REPLACE_ISWBLANK@
288 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
289 # define iswblank rpl_iswblank
291 _GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
293 _GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
298 # if defined __MINGW32__
300 /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
301 The functions towlower and towupper are implemented in the MSVCRT library
302 to take a wchar_t argument and return a wchar_t result. mingw declares
303 these functions to take a wint_t argument and return a wint_t result.
305 1. When the user passes an argument outside the range 0x0000..0xFFFF, the
306 function will look only at the lower 16 bits. This is allowed according
308 2. The return value is returned in the lower 16 bits of the result register.
309 The upper 16 bits are random: whatever happened to be in that part of the
310 result register. We need to fix this by adding a zero-extend from
311 wchar_t to wint_t after the call. */
314 rpl_towlower (wint_t wc)
316 return (wint_t) (wchar_t) towlower (wc);
318 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
319 # define towlower rpl_towlower
323 rpl_towupper (wint_t wc)
325 return (wint_t) (wchar_t) towupper (wc);
327 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
328 # define towupper rpl_towupper
331 # endif /* __MINGW32__ */
333 # define GNULIB_defined_wctype_functions 1
336 #if @REPLACE_ISWCNTRL@
337 _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
338 _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
339 _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
340 _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
341 _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
342 _GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
343 _GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
344 _GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
345 _GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
346 _GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
347 _GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
349 _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
350 _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
351 _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
352 _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
353 _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
354 _GL_CXXALIAS_SYS (iswlower, int, (wint_t wc));
355 _GL_CXXALIAS_SYS (iswprint, int, (wint_t wc));
356 _GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc));
357 _GL_CXXALIAS_SYS (iswspace, int, (wint_t wc));
358 _GL_CXXALIAS_SYS (iswupper, int, (wint_t wc));
359 _GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
361 _GL_CXXALIASWARN (iswalnum);
362 _GL_CXXALIASWARN (iswalpha);
363 _GL_CXXALIASWARN (iswcntrl);
364 _GL_CXXALIASWARN (iswdigit);
365 _GL_CXXALIASWARN (iswgraph);
366 _GL_CXXALIASWARN (iswlower);
367 _GL_CXXALIASWARN (iswprint);
368 _GL_CXXALIASWARN (iswpunct);
369 _GL_CXXALIASWARN (iswspace);
370 _GL_CXXALIASWARN (iswupper);
371 _GL_CXXALIASWARN (iswxdigit);
373 #if @GNULIB_ISWBLANK@
374 # if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@
375 _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
377 _GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
379 _GL_CXXALIASWARN (iswblank);
383 # if !GNULIB_defined_wctype_t
384 typedef void * wctype_t;
385 # define GNULIB_defined_wctype_t 1
389 /* Get a descriptor for a wide character property. */
391 # if !@HAVE_WCTYPE_T@
392 _GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name));
394 _GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
395 _GL_CXXALIASWARN (wctype);
396 #elif defined GNULIB_POSIXCHECK
398 # if HAVE_RAW_DECL_WCTYPE
399 _GL_WARN_ON_USE (wctype, "wctype is unportable - "
400 "use gnulib module wctype for portability");
404 /* Test whether a wide character has a given property.
405 The argument WC must be either a wchar_t value or WEOF.
406 The argument DESC must have been returned by the wctype() function. */
407 #if @GNULIB_ISWCTYPE@
408 # if !@HAVE_WCTYPE_T@
409 _GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc));
411 _GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
412 _GL_CXXALIASWARN (iswctype);
413 #elif defined GNULIB_POSIXCHECK
415 # if HAVE_RAW_DECL_ISWCTYPE
416 _GL_WARN_ON_USE (iswctype, "iswctype is unportable - "
417 "use gnulib module iswctype for portability");
421 #if @REPLACE_ISWCNTRL@ || defined __MINGW32__
422 _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
423 _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
425 _GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc));
426 _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
428 _GL_CXXALIASWARN (towlower);
429 _GL_CXXALIASWARN (towupper);
431 #if !@HAVE_WCTRANS_T@
432 # if !GNULIB_defined_wctrans_t
433 typedef void * wctrans_t;
434 # define GNULIB_defined_wctrans_t 1
438 /* Get a descriptor for a wide character case conversion. */
440 # if !@HAVE_WCTRANS_T@
441 _GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name));
443 _GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
444 _GL_CXXALIASWARN (wctrans);
445 #elif defined GNULIB_POSIXCHECK
447 # if HAVE_RAW_DECL_WCTRANS
448 _GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
449 "use gnulib module wctrans for portability");
453 /* Perform a given case conversion on a wide character.
454 The argument WC must be either a wchar_t value or WEOF.
455 The argument DESC must have been returned by the wctrans() function. */
456 #if @GNULIB_TOWCTRANS@
457 # if !@HAVE_WCTRANS_T@
458 _GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
460 _GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
461 _GL_CXXALIASWARN (towctrans);
462 #elif defined GNULIB_POSIXCHECK
464 # if HAVE_RAW_DECL_TOWCTRANS
465 _GL_WARN_ON_USE (towctrans, "towctrans is unportable - "
466 "use gnulib module towctrans for portability");
471 #endif /* _GL_WCTYPE_H */
472 #endif /* _GL_WCTYPE_H */