summaryrefslogtreecommitdiffstats
path: root/gl/wctype.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/wctype.in.h')
-rw-r--r--gl/wctype.in.h59
1 files changed, 41 insertions, 18 deletions
diff --git a/gl/wctype.in.h b/gl/wctype.in.h
index a86b5ad..f008d8f 100644
--- a/gl/wctype.in.h
+++ b/gl/wctype.in.h
@@ -1,6 +1,6 @@
1/* A substitute for ISO C99 <wctype.h>, for platforms that lack it. 1/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
2 2
3 Copyright (C) 2006, 2007 Free Software Foundation, Inc. 3 Copyright (C) 2006-2008 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published by
@@ -28,6 +28,10 @@
28 28
29#ifndef _GL_WCTYPE_H 29#ifndef _GL_WCTYPE_H
30 30
31#if __GNUC__ >= 3
32@PRAGMA_SYSTEM_HEADER@
33#endif
34
31#if @HAVE_WINT_T@ 35#if @HAVE_WINT_T@
32/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. 36/* 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 37 Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
@@ -50,15 +54,18 @@
50#ifndef _GL_WCTYPE_H 54#ifndef _GL_WCTYPE_H
51#define _GL_WCTYPE_H 55#define _GL_WCTYPE_H
52 56
53#if @HAVE_WINT_T@ 57/* Define wint_t. (Also done in wchar.in.h.) */
54typedef wint_t __wctype_wint_t; 58#if !@HAVE_WINT_T@ && !defined wint_t
55#else 59# define wint_t int
56typedef int __wctype_wint_t; 60# ifndef WEOF
61# define WEOF -1
62# endif
57#endif 63#endif
58 64
59/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions. 65/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
66 Linux libc5 has <wctype.h> and the functions but they are broken.
60 Assume all 12 functions are implemented the same way, or not at all. */ 67 Assume all 12 functions are implemented the same way, or not at all. */
61#if ! @HAVE_ISWCNTRL@ 68#if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
62 69
63/* IRIX 5.3 has macros but no functions, its isw* macros refer to an 70/* 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 71 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
@@ -78,57 +85,73 @@ typedef int __wctype_wint_t;
78# undef iswupper 85# undef iswupper
79# undef iswxdigit 86# undef iswxdigit
80 87
88/* Linux libc5 has <wctype.h> and the functions but they are broken. */
89# if @REPLACE_ISWCNTRL@
90# define iswalnum rpl_iswalnum
91# define iswalpha rpl_iswalpha
92# define iswblank rpl_iswblank
93# define iswcntrl rpl_iswcntrl
94# define iswdigit rpl_iswdigit
95# define iswgraph rpl_iswgraph
96# define iswlower rpl_iswlower
97# define iswprint rpl_iswprint
98# define iswpunct rpl_iswpunct
99# define iswspace rpl_iswspace
100# define iswupper rpl_iswupper
101# define iswxdigit rpl_iswxdigit
102# endif
103
81static inline int 104static inline int
82iswalnum (__wctype_wint_t wc) 105iswalnum (wint_t wc)
83{ 106{
84 return ((wc >= '0' && wc <= '9') 107 return ((wc >= '0' && wc <= '9')
85 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); 108 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
86} 109}
87 110
88static inline int 111static inline int
89iswalpha (__wctype_wint_t wc) 112iswalpha (wint_t wc)
90{ 113{
91 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; 114 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
92} 115}
93 116
94static inline int 117static inline int
95iswblank (__wctype_wint_t wc) 118iswblank (wint_t wc)
96{ 119{
97 return wc == ' ' || wc == '\t'; 120 return wc == ' ' || wc == '\t';
98} 121}
99 122
100static inline int 123static inline int
101iswcntrl (__wctype_wint_t wc) 124iswcntrl (wint_t wc)
102{ 125{
103 return (wc & ~0x1f) == 0 || wc == 0x7f; 126 return (wc & ~0x1f) == 0 || wc == 0x7f;
104} 127}
105 128
106static inline int 129static inline int
107iswdigit (__wctype_wint_t wc) 130iswdigit (wint_t wc)
108{ 131{
109 return wc >= '0' && wc <= '9'; 132 return wc >= '0' && wc <= '9';
110} 133}
111 134
112static inline int 135static inline int
113iswgraph (__wctype_wint_t wc) 136iswgraph (wint_t wc)
114{ 137{
115 return wc >= '!' && wc <= '~'; 138 return wc >= '!' && wc <= '~';
116} 139}
117 140
118static inline int 141static inline int
119iswlower (__wctype_wint_t wc) 142iswlower (wint_t wc)
120{ 143{
121 return wc >= 'a' && wc <= 'z'; 144 return wc >= 'a' && wc <= 'z';
122} 145}
123 146
124static inline int 147static inline int
125iswprint (__wctype_wint_t wc) 148iswprint (wint_t wc)
126{ 149{
127 return wc >= ' ' && wc <= '~'; 150 return wc >= ' ' && wc <= '~';
128} 151}
129 152
130static inline int 153static inline int
131iswpunct (__wctype_wint_t wc) 154iswpunct (wint_t wc)
132{ 155{
133 return (wc >= '!' && wc <= '~' 156 return (wc >= '!' && wc <= '~'
134 && !((wc >= '0' && wc <= '9') 157 && !((wc >= '0' && wc <= '9')
@@ -136,20 +159,20 @@ iswpunct (__wctype_wint_t wc)
136} 159}
137 160
138static inline int 161static inline int
139iswspace (__wctype_wint_t wc) 162iswspace (wint_t wc)
140{ 163{
141 return (wc == ' ' || wc == '\t' 164 return (wc == ' ' || wc == '\t'
142 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); 165 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
143} 166}
144 167
145static inline int 168static inline int
146iswupper (__wctype_wint_t wc) 169iswupper (wint_t wc)
147{ 170{
148 return wc >= 'A' && wc <= 'Z'; 171 return wc >= 'A' && wc <= 'Z';
149} 172}
150 173
151static inline int 174static inline int
152iswxdigit (__wctype_wint_t wc) 175iswxdigit (wint_t wc)
153{ 176{
154 return ((wc >= '0' && wc <= '9') 177 return ((wc >= '0' && wc <= '9')
155 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); 178 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));