summaryrefslogtreecommitdiffstats
path: root/gl/wctype.in.h
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2008-02-12 11:07:18 (GMT)
committerThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2008-02-12 11:07:18 (GMT)
commitbd7029a99b0c2974265c6665638ef14a052f42ab (patch)
treef5661ba73366d81ef6e91f889ea7fec5ebe07b6b /gl/wctype.in.h
parentf99612320d6eda67644c07be04bb21aa4d7789db (diff)
downloadmonitoring-plugins-bd7029a99b0c2974265c6665638ef14a052f42ab.tar.gz
Sync to latest Gnulib
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1925 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'gl/wctype.in.h')
-rw-r--r--gl/wctype.in.h161
1 files changed, 161 insertions, 0 deletions
diff --git a/gl/wctype.in.h b/gl/wctype.in.h
new file mode 100644
index 0000000..a86b5ad
--- /dev/null
+++ b/gl/wctype.in.h
@@ -0,0 +1,161 @@
1/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
2
3 Copyright (C) 2006, 2007 Free Software Foundation, Inc.
4
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 3, or (at your option)
8 any later version.
9
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.
14
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. */
18
19/* Written by Bruno Haible and Paul Eggert. */
20
21/*
22 * ISO C 99 <wctype.h> for platforms that lack it.
23 * <http://www.opengroup.org/susv3xbd/wctype.h.html>
24 *
25 * iswctype, towctrans, towlower, towupper, wctrans, wctype,
26 * wctrans_t, and wctype_t are not yet implemented.
27 */
28
29#ifndef _GL_WCTYPE_H
30
31#if @HAVE_WINT_T@
32/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
33 Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
34 <wchar.h>.
35 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
36 included before <wchar.h>. */
37# include <stddef.h>
38# include <stdio.h>
39# include <time.h>
40# include <wchar.h>
41#endif
42
43/* Include the original <wctype.h> if it exists.
44 BeOS 5 has the functions but no <wctype.h>. */
45/* The include_next requires a split double-inclusion guard. */
46#if @HAVE_WCTYPE_H@
47# @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
48#endif
49
50#ifndef _GL_WCTYPE_H
51#define _GL_WCTYPE_H
52
53#if @HAVE_WINT_T@
54typedef wint_t __wctype_wint_t;
55#else
56typedef int __wctype_wint_t;
57#endif
58
59/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
60 Assume all 12 functions are implemented the same way, or not at all. */
61#if ! @HAVE_ISWCNTRL@
62
63/* IRIX 5.3 has macros but no functions, its isw* macros refer to an
64 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
65 refer to system functions like _iswctype that are not in the
66 standard C library. Rather than try to get ancient buggy
67 implementations like this to work, just disable them. */
68# undef iswalnum
69# undef iswalpha
70# undef iswblank
71# undef iswcntrl
72# undef iswdigit
73# undef iswgraph
74# undef iswlower
75# undef iswprint
76# undef iswpunct
77# undef iswspace
78# undef iswupper
79# undef iswxdigit
80
81static inline int
82iswalnum (__wctype_wint_t wc)
83{
84 return ((wc >= '0' && wc <= '9')
85 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
86}
87
88static inline int
89iswalpha (__wctype_wint_t wc)
90{
91 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
92}
93
94static inline int
95iswblank (__wctype_wint_t wc)
96{
97 return wc == ' ' || wc == '\t';
98}
99
100static inline int
101iswcntrl (__wctype_wint_t wc)
102{
103 return (wc & ~0x1f) == 0 || wc == 0x7f;
104}
105
106static inline int
107iswdigit (__wctype_wint_t wc)
108{
109 return wc >= '0' && wc <= '9';
110}
111
112static inline int
113iswgraph (__wctype_wint_t wc)
114{
115 return wc >= '!' && wc <= '~';
116}
117
118static inline int
119iswlower (__wctype_wint_t wc)
120{
121 return wc >= 'a' && wc <= 'z';
122}
123
124static inline int
125iswprint (__wctype_wint_t wc)
126{
127 return wc >= ' ' && wc <= '~';
128}
129
130static inline int
131iswpunct (__wctype_wint_t wc)
132{
133 return (wc >= '!' && wc <= '~'
134 && !((wc >= '0' && wc <= '9')
135 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
136}
137
138static inline int
139iswspace (__wctype_wint_t wc)
140{
141 return (wc == ' ' || wc == '\t'
142 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
143}
144
145static inline int
146iswupper (__wctype_wint_t wc)
147{
148 return wc >= 'A' && wc <= 'Z';
149}
150
151static inline int
152iswxdigit (__wctype_wint_t wc)
153{
154 return ((wc >= '0' && wc <= '9')
155 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
156}
157
158# endif /* ! HAVE_ISWCNTRL */
159
160#endif /* _GL_WCTYPE_H */
161#endif /* _GL_WCTYPE_H */