1 /* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
3 Copyright (C) 2006 Free Software Foundation, Inc.
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 2, or (at your option)
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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 /* Written by Bruno Haible and Paul Eggert. */
22 * ISO C 99 <wctype.h> for platforms that lack it.
23 * <http://www.opengroup.org/susv3xbd/wctype.h.html>
25 * iswctype, towctrans, towlower, towupper, wctrans, wctype,
26 * wctrans_t, and wctype_t are not yet implemented.
33 /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
34 Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
36 BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
41 typedef wint_t __wctype_wint_t
;
43 typedef int __wctype_wint_t
;
46 /* Include the original <wctype.h> if it exists.
47 BeOS 5 has the functions but no <wctype.h>. */
49 # include @ABSOLUTE_WCTYPE_H@
52 /* IRIX 5.3 has a bug: its isw* macros reference an undefined variable
54 #if @HAVE_WCTYPE_CTMP_BUG@
58 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
59 Assume all 12 functions are implemented the same way, or not at all. */
61 #if !defined iswalnum && !HAVE_ISWCNTRL
63 iswalnum (__wctype_wint_t wc
)
65 return ((wc
>= '0' && wc
<= '9')
66 || ((wc
& ~0x20) >= 'A' && (wc
& ~0x20) <= 'Z'));
68 # define iswalnum iswalnum
71 #if !defined iswalpha && !HAVE_ISWCNTRL
73 iswalpha (__wctype_wint_t wc
)
75 return (wc
& ~0x20) >= 'A' && (wc
& ~0x20) <= 'Z';
77 # define iswalpha iswalpha
80 #if !defined iswblank && !HAVE_ISWCNTRL
82 iswblank (__wctype_wint_t wc
)
84 return wc
== ' ' || wc
== '\t';
86 # define iswblank iswblank
89 #if !defined iswcntrl && !HAVE_ISWCNTRL
91 iswcntrl (__wctype_wint_t wc
)
93 return (wc
& ~0x1f) == 0 || wc
== 0x7f;
95 # define iswcntrl iswcntrl
98 #if !defined iswdigit && !HAVE_ISWCNTRL
100 iswdigit (__wctype_wint_t wc
)
102 return wc
>= '0' && wc
<= '9';
104 # define iswdigit iswdigit
107 #if !defined iswgraph && !HAVE_ISWCNTRL
109 iswgraph (__wctype_wint_t wc
)
111 return wc
>= '!' && wc
<= '~';
113 # define iswgraph iswgraph
116 #if !defined iswlower && !HAVE_ISWCNTRL
118 iswlower (__wctype_wint_t wc
)
120 return wc
>= 'a' && wc
<= 'z';
122 # define iswlower iswlower
125 #if !defined iswprint && !HAVE_ISWCNTRL
127 iswprint (__wctype_wint_t wc
)
129 return wc
>= ' ' && wc
<= '~';
131 # define iswprint iswprint
134 #if !defined iswpunct && !HAVE_ISWCNTRL
136 iswpunct (__wctype_wint_t wc
)
138 return (wc
>= '!' && wc
<= '~'
139 && !((wc
>= '0' && wc
<= '9')
140 || ((wc
& ~0x20) >= 'A' && (wc
& ~0x20) <= 'Z')));
142 # define iswpunct iswpunct
145 #if !defined iswspace && !HAVE_ISWCNTRL
147 iswspace (__wctype_wint_t wc
)
149 return (wc
== ' ' || wc
== '\t'
150 || wc
== '\n' || wc
== '\v' || wc
== '\f' || wc
== '\r');
152 # define iswspace iswspace
155 #if !defined iswupper && !HAVE_ISWCNTRL
157 iswupper (__wctype_wint_t wc
)
159 return wc
>= 'A' && wc
<= 'Z';
161 # define iswupper iswupper
164 #if !defined iswxdigit && !HAVE_ISWCNTRL
166 iswxdigit (__wctype_wint_t wc
)
168 return ((wc
>= '0' && wc
<= '9')
169 || ((wc
& ~0x20) >= 'A' && (wc
& ~0x20) <= 'F'));
171 # define iswxdigit iswxdigit
175 #endif /* _GL_WCTYPE_H */