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. */
21 /* iswctype, towctrans, towlower, towupper, wctrans, wctype,
22 wctrans_t, and wctype_t are not yet implemented. */
27 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
29 BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
36 # include @ABSOLUTE_WCTYPE_H@
39 #if @HAVE_WCTYPE_CTMP_BUG@
43 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
44 Assume all 12 functions are implemented the same way, or not at all. */
46 #if !defined iswalnum && !HAVE_ISWCNTRL
50 return ((wc >= '0' && wc <= '9')
51 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
53 # define iswalnum iswalnum
56 #if !defined iswalpha && !HAVE_ISWCNTRL
60 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
62 # define iswalpha iswalpha
65 #if !defined iswblank && !HAVE_ISWCNTRL
69 return wc == ' ' || wc == '\t';
71 # define iswblank iswblank
74 #if !defined iswcntrl && !HAVE_ISWCNTRL
78 return (wc & ~0x1f) == 0 || wc == 0x7f;
80 # define iswcntrl iswcntrl
83 #if !defined iswdigit && !HAVE_ISWCNTRL
87 return wc >= '0' && wc <= '9';
89 # define iswdigit iswdigit
92 #if !defined iswgraph && !HAVE_ISWCNTRL
96 return wc >= '!' && wc <= '~';
98 # define iswgraph iswgraph
101 #if !defined iswlower && !HAVE_ISWCNTRL
105 return wc >= 'a' && wc <= 'z';
107 # define iswlower iswlower
110 #if !defined iswprint && !HAVE_ISWCNTRL
114 return wc >= ' ' && wc <= '~';
116 # define iswprint iswprint
119 #if !defined iswpunct && !HAVE_ISWCNTRL
123 return (wc >= '!' && wc <= '~'
124 && !((wc >= '0' && wc <= '9')
125 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
127 # define iswpunct iswpunct
130 #if !defined iswspace && !HAVE_ISWCNTRL
134 return (wc == ' ' || wc == '\t'
135 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
137 # define iswspace iswspace
140 #if !defined iswupper && !HAVE_ISWCNTRL
144 return wc >= 'A' && wc <= 'Z';
146 # define iswupper iswupper
149 #if !defined iswxdigit && !HAVE_ISWCNTRL
151 iswxdigit (wint_t wc)
153 return ((wc >= '0' && wc <= '9')
154 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
156 # define iswxdigit iswxdigit
160 #endif /* _GL_WCTYPE_H */