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-2010 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 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
78 Linux libc5 has <wctype.h> and the functions but they are broken.
79 Assume all 11 functions (all isw* except iswblank) are implemented the
80 same way, or not at all. */
81 #if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
83 /* IRIX 5.3 has macros but no functions, its isw* macros refer to an
84 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
85 refer to system functions like _iswctype that are not in the
86 standard C library. Rather than try to get ancient buggy
87 implementations like this to work, just disable them. */
103 /* Linux libc5 has <wctype.h> and the functions but they are broken. */
104 # if @REPLACE_ISWCNTRL@
105 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
106 # define iswalnum rpl_iswalnum
107 # define iswalpha rpl_iswalpha
108 # define iswblank rpl_iswblank
109 # define iswcntrl rpl_iswcntrl
110 # define iswdigit rpl_iswdigit
111 # define iswgraph rpl_iswgraph
112 # define iswlower rpl_iswlower
113 # define iswprint rpl_iswprint
114 # define iswpunct rpl_iswpunct
115 # define iswspace rpl_iswspace
116 # define iswupper rpl_iswupper
117 # define iswxdigit rpl_iswxdigit
118 # define towlower rpl_towlower
119 # define towupper rpl_towupper
124 # if @REPLACE_ISWCNTRL@
131 return ((wc >= '0' && wc <= '9')
132 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
136 # if @REPLACE_ISWCNTRL@
143 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
147 # if @REPLACE_ISWCNTRL@
154 return wc == ' ' || wc == '\t';
158 # if @REPLACE_ISWCNTRL@
165 return (wc & ~0x1f) == 0 || wc == 0x7f;
169 # if @REPLACE_ISWCNTRL@
176 return wc >= '0' && wc <= '9';
180 # if @REPLACE_ISWCNTRL@
187 return wc >= '!' && wc <= '~';
191 # if @REPLACE_ISWCNTRL@
198 return wc >= 'a' && wc <= 'z';
202 # if @REPLACE_ISWCNTRL@
209 return wc >= ' ' && wc <= '~';
213 # if @REPLACE_ISWCNTRL@
220 return (wc >= '!' && wc <= '~'
221 && !((wc >= '0' && wc <= '9')
222 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
226 # if @REPLACE_ISWCNTRL@
233 return (wc == ' ' || wc == '\t'
234 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
238 # if @REPLACE_ISWCNTRL@
245 return wc >= 'A' && wc <= 'Z';
249 # if @REPLACE_ISWCNTRL@
256 return ((wc >= '0' && wc <= '9')
257 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
261 # if @REPLACE_ISWCNTRL@
268 return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
272 # if @REPLACE_ISWCNTRL@
279 return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
282 #elif ! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@
283 /* Only the iswblank function is missing. */
285 # if @REPLACE_ISWBLANK@
286 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
287 # define iswblank rpl_iswblank
292 # if @REPLACE_ISWBLANK@
299 return wc == ' ' || wc == '\t';
304 #if defined __MINGW32__
306 /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
307 The functions towlower and towupper are implemented in the MSVCRT library
308 to take a wchar_t argument and return a wchar_t result. mingw declares
309 these functions to take a wint_t argument and return a wint_t result.
311 1. When the user passes an argument outside the range 0x0000..0xFFFF, the
312 function will look only at the lower 16 bits. This is allowed according
314 2. The return value is returned in the lower 16 bits of the result register.
315 The upper 16 bits are random: whatever happened to be in that part of the
316 result register. We need to fix this by adding a zero-extend from
317 wchar_t to wint_t after the call. */
320 rpl_towlower (wint_t wc)
322 return (wint_t) (wchar_t) towlower (wc);
324 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
325 # define towlower rpl_towlower
329 rpl_towupper (wint_t wc)
331 return (wint_t) (wchar_t) towupper (wc);
333 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
334 # define towupper rpl_towupper
337 #endif /* __MINGW32__ */
339 #if @REPLACE_ISWCNTRL@
340 _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
341 _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
342 _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
343 _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
344 _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
345 _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
346 _GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
347 _GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
348 _GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
349 _GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
350 _GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
351 _GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
353 _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
354 _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
355 # if @REPLACE_ISWBLANK@
356 _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
358 _GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
360 _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
361 _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
362 _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
363 _GL_CXXALIAS_SYS (iswlower, int, (wint_t wc));
364 _GL_CXXALIAS_SYS (iswprint, int, (wint_t wc));
365 _GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc));
366 _GL_CXXALIAS_SYS (iswspace, int, (wint_t wc));
367 _GL_CXXALIAS_SYS (iswupper, int, (wint_t wc));
368 _GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
370 _GL_CXXALIASWARN (iswalnum);
371 _GL_CXXALIASWARN (iswalpha);
372 _GL_CXXALIASWARN (iswblank);
373 _GL_CXXALIASWARN (iswcntrl);
374 _GL_CXXALIASWARN (iswdigit);
375 _GL_CXXALIASWARN (iswgraph);
376 _GL_CXXALIASWARN (iswlower);
377 _GL_CXXALIASWARN (iswprint);
378 _GL_CXXALIASWARN (iswpunct);
379 _GL_CXXALIASWARN (iswspace);
380 _GL_CXXALIASWARN (iswupper);
381 _GL_CXXALIASWARN (iswxdigit);
383 #if @REPLACE_ISWCNTRL@ || defined __MINGW32__
384 _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
385 _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
387 _GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc));
388 _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
390 _GL_CXXALIASWARN (towlower);
391 _GL_CXXALIASWARN (towupper);
394 #endif /* _GL_WCTYPE_H */
395 #endif /* _GL_WCTYPE_H */