]> git.cworth.org Git - tar/blob - lib/wctype.in.h
Imported Upstream version 1.21
[tar] / lib / wctype.in.h
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.
4
5    Copyright (C) 2006-2008 Free Software Foundation, Inc.
6
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)
10    any later version.
11
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.
16
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.  */
20
21 /* Written by Bruno Haible and Paul Eggert.  */
22
23 /*
24  * ISO C 99 <wctype.h> for platforms that lack it.
25  * <http://www.opengroup.org/susv3xbd/wctype.h.html>
26  *
27  * iswctype, towctrans, towlower, towupper, wctrans, wctype,
28  * wctrans_t, and wctype_t are not yet implemented.
29  */
30
31 #ifndef _GL_WCTYPE_H
32
33 #if __GNUC__ >= 3
34 @PRAGMA_SYSTEM_HEADER@
35 #endif
36
37 #if @HAVE_WINT_T@
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
40    <wchar.h>.
41    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
42    included before <wchar.h>.  */
43 # include <stddef.h>
44 # include <stdio.h>
45 # include <time.h>
46 # include <wchar.h>
47 #endif
48
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.  */
52 #if @HAVE_WCTYPE_H@
53 # @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
54 #endif
55
56 #ifndef _GL_WCTYPE_H
57 #define _GL_WCTYPE_H
58
59 /* Define wint_t.  (Also done in wchar.in.h.)  */
60 #if !@HAVE_WINT_T@ && !defined wint_t
61 # define wint_t int
62 #endif
63
64 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
65    Linux libc5 has <wctype.h> and the functions but they are broken.
66    Assume all 12 functions are implemented the same way, or not at all.  */
67 #if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
68
69 /* IRIX 5.3 has macros but no functions, its isw* macros refer to an
70    undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
71    refer to system functions like _iswctype that are not in the
72    standard C library.  Rather than try to get ancient buggy
73    implementations like this to work, just disable them.  */
74 #  undef iswalnum
75 #  undef iswalpha
76 #  undef iswblank
77 #  undef iswcntrl
78 #  undef iswdigit
79 #  undef iswgraph
80 #  undef iswlower
81 #  undef iswprint
82 #  undef iswpunct
83 #  undef iswspace
84 #  undef iswupper
85 #  undef iswxdigit
86
87 /* Linux libc5 has <wctype.h> and the functions but they are broken.  */
88 #  if @REPLACE_ISWCNTRL@
89 #   define iswalnum rpl_iswalnum
90 #   define iswalpha rpl_iswalpha
91 #   define iswblank rpl_iswblank
92 #   define iswcntrl rpl_iswcntrl
93 #   define iswdigit rpl_iswdigit
94 #   define iswgraph rpl_iswgraph
95 #   define iswlower rpl_iswlower
96 #   define iswprint rpl_iswprint
97 #   define iswpunct rpl_iswpunct
98 #   define iswspace rpl_iswspace
99 #   define iswupper rpl_iswupper
100 #   define iswxdigit rpl_iswxdigit
101 #  endif
102
103 static inline int
104 iswalnum (wint_t wc)
105 {
106   return ((wc >= '0' && wc <= '9')
107           || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
108 }
109
110 static inline int
111 iswalpha (wint_t wc)
112 {
113   return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
114 }
115
116 static inline int
117 iswblank (wint_t wc)
118 {
119   return wc == ' ' || wc == '\t';
120 }
121
122 static inline int
123 iswcntrl (wint_t wc)
124 {
125   return (wc & ~0x1f) == 0 || wc == 0x7f;
126 }
127
128 static inline int
129 iswdigit (wint_t wc)
130 {
131   return wc >= '0' && wc <= '9';
132 }
133
134 static inline int
135 iswgraph (wint_t wc)
136 {
137   return wc >= '!' && wc <= '~';
138 }
139
140 static inline int
141 iswlower (wint_t wc)
142 {
143   return wc >= 'a' && wc <= 'z';
144 }
145
146 static inline int
147 iswprint (wint_t wc)
148 {
149   return wc >= ' ' && wc <= '~';
150 }
151
152 static inline int
153 iswpunct (wint_t wc)
154 {
155   return (wc >= '!' && wc <= '~'
156           && !((wc >= '0' && wc <= '9')
157                || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
158 }
159
160 static inline int
161 iswspace (wint_t wc)
162 {
163   return (wc == ' ' || wc == '\t'
164           || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
165 }
166
167 static inline int
168 iswupper (wint_t wc)
169 {
170   return wc >= 'A' && wc <= 'Z';
171 }
172
173 static inline int
174 iswxdigit (wint_t wc)
175 {
176   return ((wc >= '0' && wc <= '9')
177           || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
178 }
179
180 # endif /* ! HAVE_ISWCNTRL */
181
182 #endif /* _GL_WCTYPE_H */
183 #endif /* _GL_WCTYPE_H */