]> git.cworth.org Git - tar/blob - lib/wctype.in.h
Imported Upstream version 1.20
[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, 2007 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 @HAVE_WINT_T@
34 /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
35    Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
36    <wchar.h>.
37    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
38    included before <wchar.h>.  */
39 # include <stddef.h>
40 # include <stdio.h>
41 # include <time.h>
42 # include <wchar.h>
43 #endif
44
45 /* Include the original <wctype.h> if it exists.
46    BeOS 5 has the functions but no <wctype.h>.  */
47 /* The include_next requires a split double-inclusion guard.  */
48 #if @HAVE_WCTYPE_H@
49 # @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
50 #endif
51
52 #ifndef _GL_WCTYPE_H
53 #define _GL_WCTYPE_H
54
55 #if @HAVE_WINT_T@
56 typedef wint_t __wctype_wint_t;
57 #else
58 typedef int __wctype_wint_t;
59 #endif
60
61 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
62    Assume all 12 functions are implemented the same way, or not at all.  */
63 #if ! @HAVE_ISWCNTRL@
64
65 /* IRIX 5.3 has macros but no functions, its isw* macros refer to an
66    undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
67    refer to system functions like _iswctype that are not in the
68    standard C library.  Rather than try to get ancient buggy
69    implementations like this to work, just disable them.  */
70 #  undef iswalnum
71 #  undef iswalpha
72 #  undef iswblank
73 #  undef iswcntrl
74 #  undef iswdigit
75 #  undef iswgraph
76 #  undef iswlower
77 #  undef iswprint
78 #  undef iswpunct
79 #  undef iswspace
80 #  undef iswupper
81 #  undef iswxdigit
82
83 static inline int
84 iswalnum (__wctype_wint_t wc)
85 {
86   return ((wc >= '0' && wc <= '9')
87           || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
88 }
89
90 static inline int
91 iswalpha (__wctype_wint_t wc)
92 {
93   return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
94 }
95
96 static inline int
97 iswblank (__wctype_wint_t wc)
98 {
99   return wc == ' ' || wc == '\t';
100 }
101
102 static inline int
103 iswcntrl (__wctype_wint_t wc)
104 {
105   return (wc & ~0x1f) == 0 || wc == 0x7f;
106 }
107
108 static inline int
109 iswdigit (__wctype_wint_t wc)
110 {
111   return wc >= '0' && wc <= '9';
112 }
113
114 static inline int
115 iswgraph (__wctype_wint_t wc)
116 {
117   return wc >= '!' && wc <= '~';
118 }
119
120 static inline int
121 iswlower (__wctype_wint_t wc)
122 {
123   return wc >= 'a' && wc <= 'z';
124 }
125
126 static inline int
127 iswprint (__wctype_wint_t wc)
128 {
129   return wc >= ' ' && wc <= '~';
130 }
131
132 static inline int
133 iswpunct (__wctype_wint_t wc)
134 {
135   return (wc >= '!' && wc <= '~'
136           && !((wc >= '0' && wc <= '9')
137                || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
138 }
139
140 static inline int
141 iswspace (__wctype_wint_t wc)
142 {
143   return (wc == ' ' || wc == '\t'
144           || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
145 }
146
147 static inline int
148 iswupper (__wctype_wint_t wc)
149 {
150   return wc >= 'A' && wc <= 'Z';
151 }
152
153 static inline int
154 iswxdigit (__wctype_wint_t wc)
155 {
156   return ((wc >= '0' && wc <= '9')
157           || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
158 }
159
160 # endif /* ! HAVE_ISWCNTRL */
161
162 #endif /* _GL_WCTYPE_H */
163 #endif /* _GL_WCTYPE_H */