diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-08 01:11:46 (GMT) |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-13 01:26:35 (GMT) |
commit | 74da141e618ef99959d509cb2e7be35a348a39db (patch) | |
tree | 88ebc38b381a1021fc2d74864a71e230ae591c3d /gl/wctype.in.h | |
parent | c63a4f726a0b6ad8cf6040f947754a81fd4683bb (diff) | |
download | monitoring-plugins-74da141e618ef99959d509cb2e7be35a348a39db.tar.gz |
Sync with the latest Gnulib code (177f525)
Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>
Diffstat (limited to 'gl/wctype.in.h')
-rw-r--r-- | gl/wctype.in.h | 261 |
1 files changed, 227 insertions, 34 deletions
diff --git a/gl/wctype.in.h b/gl/wctype.in.h index f008d8f..0f0859c 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-2008 Free Software Foundation, Inc. | 3 | Copyright (C) 2006-2010 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 |
@@ -54,17 +54,27 @@ | |||
54 | #ifndef _GL_WCTYPE_H | 54 | #ifndef _GL_WCTYPE_H |
55 | #define _GL_WCTYPE_H | 55 | #define _GL_WCTYPE_H |
56 | 56 | ||
57 | /* Define wint_t. (Also done in wchar.in.h.) */ | 57 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
58 | |||
59 | /* The definition of _GL_WARN_ON_USE is copied here. */ | ||
60 | |||
61 | /* Define wint_t and WEOF. (Also done in wchar.in.h.) */ | ||
58 | #if !@HAVE_WINT_T@ && !defined wint_t | 62 | #if !@HAVE_WINT_T@ && !defined wint_t |
59 | # define wint_t int | 63 | # define wint_t int |
60 | # ifndef WEOF | 64 | # ifndef WEOF |
61 | # define WEOF -1 | 65 | # define WEOF -1 |
62 | # endif | 66 | # endif |
67 | #else | ||
68 | # ifndef WEOF | ||
69 | # define WEOF ((wint_t) -1) | ||
70 | # endif | ||
63 | #endif | 71 | #endif |
64 | 72 | ||
73 | |||
65 | /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions. | 74 | /* 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. | 75 | Linux libc5 has <wctype.h> and the functions but they are broken. |
67 | Assume all 12 functions are implemented the same way, or not at all. */ | 76 | Assume all 11 functions (all isw* except iswblank) are implemented the |
77 | same way, or not at all. */ | ||
68 | #if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ | 78 | #if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ |
69 | 79 | ||
70 | /* IRIX 5.3 has macros but no functions, its isw* macros refer to an | 80 | /* IRIX 5.3 has macros but no functions, its isw* macros refer to an |
@@ -72,21 +82,24 @@ | |||
72 | refer to system functions like _iswctype that are not in the | 82 | refer to system functions like _iswctype that are not in the |
73 | standard C library. Rather than try to get ancient buggy | 83 | standard C library. Rather than try to get ancient buggy |
74 | implementations like this to work, just disable them. */ | 84 | implementations like this to work, just disable them. */ |
75 | # undef iswalnum | 85 | # undef iswalnum |
76 | # undef iswalpha | 86 | # undef iswalpha |
77 | # undef iswblank | 87 | # undef iswblank |
78 | # undef iswcntrl | 88 | # undef iswcntrl |
79 | # undef iswdigit | 89 | # undef iswdigit |
80 | # undef iswgraph | 90 | # undef iswgraph |
81 | # undef iswlower | 91 | # undef iswlower |
82 | # undef iswprint | 92 | # undef iswprint |
83 | # undef iswpunct | 93 | # undef iswpunct |
84 | # undef iswspace | 94 | # undef iswspace |
85 | # undef iswupper | 95 | # undef iswupper |
86 | # undef iswxdigit | 96 | # undef iswxdigit |
97 | # undef towlower | ||
98 | # undef towupper | ||
87 | 99 | ||
88 | /* Linux libc5 has <wctype.h> and the functions but they are broken. */ | 100 | /* Linux libc5 has <wctype.h> and the functions but they are broken. */ |
89 | # if @REPLACE_ISWCNTRL@ | 101 | # if @REPLACE_ISWCNTRL@ |
102 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
90 | # define iswalnum rpl_iswalnum | 103 | # define iswalnum rpl_iswalnum |
91 | # define iswalpha rpl_iswalpha | 104 | # define iswalpha rpl_iswalpha |
92 | # define iswblank rpl_iswblank | 105 | # define iswblank rpl_iswblank |
@@ -99,86 +112,266 @@ | |||
99 | # define iswspace rpl_iswspace | 112 | # define iswspace rpl_iswspace |
100 | # define iswupper rpl_iswupper | 113 | # define iswupper rpl_iswupper |
101 | # define iswxdigit rpl_iswxdigit | 114 | # define iswxdigit rpl_iswxdigit |
115 | # define towlower rpl_towlower | ||
116 | # define towupper rpl_towupper | ||
102 | # endif | 117 | # endif |
118 | # endif | ||
103 | 119 | ||
104 | static inline int | 120 | static inline int |
105 | iswalnum (wint_t wc) | 121 | # if @REPLACE_ISWCNTRL@ |
122 | rpl_iswalnum | ||
123 | # else | ||
124 | iswalnum | ||
125 | # endif | ||
126 | (wint_t wc) | ||
106 | { | 127 | { |
107 | return ((wc >= '0' && wc <= '9') | 128 | return ((wc >= '0' && wc <= '9') |
108 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); | 129 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); |
109 | } | 130 | } |
110 | 131 | ||
111 | static inline int | 132 | static inline int |
112 | iswalpha (wint_t wc) | 133 | # if @REPLACE_ISWCNTRL@ |
134 | rpl_iswalpha | ||
135 | # else | ||
136 | iswalpha | ||
137 | # endif | ||
138 | (wint_t wc) | ||
113 | { | 139 | { |
114 | return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; | 140 | return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; |
115 | } | 141 | } |
116 | 142 | ||
117 | static inline int | 143 | static inline int |
118 | iswblank (wint_t wc) | 144 | # if @REPLACE_ISWCNTRL@ |
145 | rpl_iswblank | ||
146 | # else | ||
147 | iswblank | ||
148 | # endif | ||
149 | (wint_t wc) | ||
119 | { | 150 | { |
120 | return wc == ' ' || wc == '\t'; | 151 | return wc == ' ' || wc == '\t'; |
121 | } | 152 | } |
122 | 153 | ||
123 | static inline int | 154 | static inline int |
124 | iswcntrl (wint_t wc) | 155 | # if @REPLACE_ISWCNTRL@ |
156 | rpl_iswcntrl | ||
157 | # else | ||
158 | iswcntrl | ||
159 | # endif | ||
160 | (wint_t wc) | ||
125 | { | 161 | { |
126 | return (wc & ~0x1f) == 0 || wc == 0x7f; | 162 | return (wc & ~0x1f) == 0 || wc == 0x7f; |
127 | } | 163 | } |
128 | 164 | ||
129 | static inline int | 165 | static inline int |
130 | iswdigit (wint_t wc) | 166 | # if @REPLACE_ISWCNTRL@ |
167 | rpl_iswdigit | ||
168 | # else | ||
169 | iswdigit | ||
170 | # endif | ||
171 | (wint_t wc) | ||
131 | { | 172 | { |
132 | return wc >= '0' && wc <= '9'; | 173 | return wc >= '0' && wc <= '9'; |
133 | } | 174 | } |
134 | 175 | ||
135 | static inline int | 176 | static inline int |
136 | iswgraph (wint_t wc) | 177 | # if @REPLACE_ISWCNTRL@ |
178 | rpl_iswgraph | ||
179 | # else | ||
180 | iswgraph | ||
181 | # endif | ||
182 | (wint_t wc) | ||
137 | { | 183 | { |
138 | return wc >= '!' && wc <= '~'; | 184 | return wc >= '!' && wc <= '~'; |
139 | } | 185 | } |
140 | 186 | ||
141 | static inline int | 187 | static inline int |
142 | iswlower (wint_t wc) | 188 | # if @REPLACE_ISWCNTRL@ |
189 | rpl_iswlower | ||
190 | # else | ||
191 | iswlower | ||
192 | # endif | ||
193 | (wint_t wc) | ||
143 | { | 194 | { |
144 | return wc >= 'a' && wc <= 'z'; | 195 | return wc >= 'a' && wc <= 'z'; |
145 | } | 196 | } |
146 | 197 | ||
147 | static inline int | 198 | static inline int |
148 | iswprint (wint_t wc) | 199 | # if @REPLACE_ISWCNTRL@ |
200 | rpl_iswprint | ||
201 | # else | ||
202 | iswprint | ||
203 | # endif | ||
204 | (wint_t wc) | ||
149 | { | 205 | { |
150 | return wc >= ' ' && wc <= '~'; | 206 | return wc >= ' ' && wc <= '~'; |
151 | } | 207 | } |
152 | 208 | ||
153 | static inline int | 209 | static inline int |
154 | iswpunct (wint_t wc) | 210 | # if @REPLACE_ISWCNTRL@ |
211 | rpl_iswpunct | ||
212 | # else | ||
213 | iswpunct | ||
214 | # endif | ||
215 | (wint_t wc) | ||
155 | { | 216 | { |
156 | return (wc >= '!' && wc <= '~' | 217 | return (wc >= '!' && wc <= '~' |
157 | && !((wc >= '0' && wc <= '9') | 218 | && !((wc >= '0' && wc <= '9') |
158 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))); | 219 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))); |
159 | } | 220 | } |
160 | 221 | ||
161 | static inline int | 222 | static inline int |
162 | iswspace (wint_t wc) | 223 | # if @REPLACE_ISWCNTRL@ |
224 | rpl_iswspace | ||
225 | # else | ||
226 | iswspace | ||
227 | # endif | ||
228 | (wint_t wc) | ||
163 | { | 229 | { |
164 | return (wc == ' ' || wc == '\t' | 230 | return (wc == ' ' || wc == '\t' |
165 | || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); | 231 | || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); |
166 | } | 232 | } |
167 | 233 | ||
168 | static inline int | 234 | static inline int |
169 | iswupper (wint_t wc) | 235 | # if @REPLACE_ISWCNTRL@ |
236 | rpl_iswupper | ||
237 | # else | ||
238 | iswupper | ||
239 | # endif | ||
240 | (wint_t wc) | ||
170 | { | 241 | { |
171 | return wc >= 'A' && wc <= 'Z'; | 242 | return wc >= 'A' && wc <= 'Z'; |
172 | } | 243 | } |
173 | 244 | ||
174 | static inline int | 245 | static inline int |
175 | iswxdigit (wint_t wc) | 246 | # if @REPLACE_ISWCNTRL@ |
247 | rpl_iswxdigit | ||
248 | # else | ||
249 | iswxdigit | ||
250 | # endif | ||
251 | (wint_t wc) | ||
176 | { | 252 | { |
177 | return ((wc >= '0' && wc <= '9') | 253 | return ((wc >= '0' && wc <= '9') |
178 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); | 254 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); |
179 | } | 255 | } |
180 | 256 | ||
181 | # endif /* ! HAVE_ISWCNTRL */ | 257 | static inline wint_t |
258 | # if @REPLACE_ISWCNTRL@ | ||
259 | rpl_towlower | ||
260 | # else | ||
261 | towlower | ||
262 | # endif | ||
263 | (wint_t wc) | ||
264 | { | ||
265 | return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc); | ||
266 | } | ||
267 | |||
268 | static inline wint_t | ||
269 | # if @REPLACE_ISWCNTRL@ | ||
270 | rpl_towupper | ||
271 | # else | ||
272 | towupper | ||
273 | # endif | ||
274 | (wint_t wc) | ||
275 | { | ||
276 | return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); | ||
277 | } | ||
278 | |||
279 | #elif ! @HAVE_ISWBLANK@ | ||
280 | /* Only the iswblank function is missing. */ | ||
281 | |||
282 | static inline int | ||
283 | iswblank (wint_t wc) | ||
284 | { | ||
285 | return wc == ' ' || wc == '\t'; | ||
286 | } | ||
287 | |||
288 | #endif | ||
289 | |||
290 | #if defined __MINGW32__ | ||
291 | |||
292 | /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t. | ||
293 | The functions towlower and towupper are implemented in the MSVCRT library | ||
294 | to take a wchar_t argument and return a wchar_t result. mingw declares | ||
295 | these functions to take a wint_t argument and return a wint_t result. | ||
296 | This means that: | ||
297 | 1. When the user passes an argument outside the range 0x0000..0xFFFF, the | ||
298 | function will look only at the lower 16 bits. This is allowed according | ||
299 | to POSIX. | ||
300 | 2. The return value is returned in the lower 16 bits of the result register. | ||
301 | The upper 16 bits are random: whatever happened to be in that part of the | ||
302 | result register. We need to fix this by adding a zero-extend from | ||
303 | wchar_t to wint_t after the call. */ | ||
304 | |||
305 | static inline wint_t | ||
306 | rpl_towlower (wint_t wc) | ||
307 | { | ||
308 | return (wint_t) (wchar_t) towlower (wc); | ||
309 | } | ||
310 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
311 | # define towlower rpl_towlower | ||
312 | # endif | ||
313 | |||
314 | static inline wint_t | ||
315 | rpl_towupper (wint_t wc) | ||
316 | { | ||
317 | return (wint_t) (wchar_t) towupper (wc); | ||
318 | } | ||
319 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
320 | # define towupper rpl_towupper | ||
321 | # endif | ||
322 | |||
323 | #endif /* __MINGW32__ */ | ||
324 | |||
325 | #if @REPLACE_ISWCNTRL@ | ||
326 | _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc)); | ||
327 | _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc)); | ||
328 | _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc)); | ||
329 | _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc)); | ||
330 | _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc)); | ||
331 | _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc)); | ||
332 | _GL_CXXALIAS_RPL (iswlower, int, (wint_t wc)); | ||
333 | _GL_CXXALIAS_RPL (iswprint, int, (wint_t wc)); | ||
334 | _GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc)); | ||
335 | _GL_CXXALIAS_RPL (iswspace, int, (wint_t wc)); | ||
336 | _GL_CXXALIAS_RPL (iswupper, int, (wint_t wc)); | ||
337 | _GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc)); | ||
338 | #else | ||
339 | _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc)); | ||
340 | _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc)); | ||
341 | _GL_CXXALIAS_SYS (iswblank, int, (wint_t wc)); | ||
342 | _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc)); | ||
343 | _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc)); | ||
344 | _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc)); | ||
345 | _GL_CXXALIAS_SYS (iswlower, int, (wint_t wc)); | ||
346 | _GL_CXXALIAS_SYS (iswprint, int, (wint_t wc)); | ||
347 | _GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc)); | ||
348 | _GL_CXXALIAS_SYS (iswspace, int, (wint_t wc)); | ||
349 | _GL_CXXALIAS_SYS (iswupper, int, (wint_t wc)); | ||
350 | _GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc)); | ||
351 | #endif | ||
352 | _GL_CXXALIASWARN (iswalnum); | ||
353 | _GL_CXXALIASWARN (iswalpha); | ||
354 | _GL_CXXALIASWARN (iswblank); | ||
355 | _GL_CXXALIASWARN (iswcntrl); | ||
356 | _GL_CXXALIASWARN (iswdigit); | ||
357 | _GL_CXXALIASWARN (iswgraph); | ||
358 | _GL_CXXALIASWARN (iswlower); | ||
359 | _GL_CXXALIASWARN (iswprint); | ||
360 | _GL_CXXALIASWARN (iswpunct); | ||
361 | _GL_CXXALIASWARN (iswspace); | ||
362 | _GL_CXXALIASWARN (iswupper); | ||
363 | _GL_CXXALIASWARN (iswxdigit); | ||
364 | |||
365 | #if @REPLACE_ISWCNTRL@ || defined __MINGW32__ | ||
366 | _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc)); | ||
367 | _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc)); | ||
368 | #else | ||
369 | _GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc)); | ||
370 | _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc)); | ||
371 | #endif | ||
372 | _GL_CXXALIASWARN (towlower); | ||
373 | _GL_CXXALIASWARN (towupper); | ||
374 | |||
182 | 375 | ||
183 | #endif /* _GL_WCTYPE_H */ | 376 | #endif /* _GL_WCTYPE_H */ |
184 | #endif /* _GL_WCTYPE_H */ | 377 | #endif /* _GL_WCTYPE_H */ |