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-2009 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@
38 /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
39 Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
41 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
42 included before <wchar.h>. */
49 /* Include the original <wctype.h> if it exists.
50 BeOS 5 has the functions but no <wctype.h>. */
51 /* The include_next requires a split double-inclusion guard. */
53 # @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
59 /* Define wint_t. (Also done in wchar.in.h.) */
60 #if !@HAVE_WINT_T@ && !defined wint_t
67 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
68 Linux libc5 has <wctype.h> and the functions but they are broken.
69 Assume all 12 functions are implemented the same way, or not at all. */
70 #if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
72 /* IRIX 5.3 has macros but no functions, its isw* macros refer to an
73 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
74 refer to system functions like _iswctype that are not in the
75 standard C library. Rather than try to get ancient buggy
76 implementations like this to work, just disable them. */
92 /* Linux libc5 has <wctype.h> and the functions but they are broken. */
93 # if @REPLACE_ISWCNTRL@
94 # define iswalnum rpl_iswalnum
95 # define iswalpha rpl_iswalpha
96 # define iswblank rpl_iswblank
97 # define iswcntrl rpl_iswcntrl
98 # define iswdigit rpl_iswdigit
99 # define iswgraph rpl_iswgraph
100 # define iswlower rpl_iswlower
101 # define iswprint rpl_iswprint
102 # define iswpunct rpl_iswpunct
103 # define iswspace rpl_iswspace
104 # define iswupper rpl_iswupper
105 # define iswxdigit rpl_iswxdigit
106 # define towlower rpl_towlower
107 # define towupper rpl_towupper
113 return ((wc >= '0' && wc <= '9')
114 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
120 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
126 return wc == ' ' || wc == '\t';
132 return (wc & ~0x1f) == 0 || wc == 0x7f;
138 return wc >= '0' && wc <= '9';
144 return wc >= '!' && wc <= '~';
150 return wc >= 'a' && wc <= 'z';
156 return wc >= ' ' && wc <= '~';
162 return (wc >= '!' && wc <= '~'
163 && !((wc >= '0' && wc <= '9')
164 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
170 return (wc == ' ' || wc == '\t'
171 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
177 return wc >= 'A' && wc <= 'Z';
181 iswxdigit (wint_t wc)
183 return ((wc >= '0' && wc <= '9')
184 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
190 return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
196 return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
199 # endif /* ! HAVE_ISWCNTRL */
201 # if defined __MINGW32__
203 /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
204 The functions towlower and towupper are implemented in the MSVCRT library
205 to take a wchar_t argument and return a wchar_t result. mingw declares
206 these functions to take a wint_t argument and return a wint_t result.
208 1. When the user passes an argument outside the range 0x0000..0xFFFF, the
209 function will look only at the lower 16 bits. This is allowed according
211 2. The return value is returned in the lower 16 bits of the result register.
212 The upper 16 bits are random: whatever happened to be in that part of the
213 result register. We need to fix this by adding a zero-extend from
214 wchar_t to wint_t after the call. */
217 rpl_towlower (wint_t wc)
219 return (wint_t) (wchar_t) towlower (wc);
221 # define towlower rpl_towlower
224 rpl_towupper (wint_t wc)
226 return (wint_t) (wchar_t) towupper (wc);
228 # define towupper rpl_towupper
232 #endif /* _GL_WCTYPE_H */
233 #endif /* _GL_WCTYPE_H */