import source from 3.0
[external/parted.git] / 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-2011 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 _@GUARD_PREFIX@_WCTYPE_H
32
33 #if __GNUC__ >= 3
34 @PRAGMA_SYSTEM_HEADER@
35 #endif
36 @PRAGMA_COLUMNS@
37
38 #if @HAVE_WINT_T@
39 /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
40    Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
41    <wchar.h>.
42    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
43    included before <wchar.h>.  */
44 # include <stddef.h>
45 # include <stdio.h>
46 # include <time.h>
47 # include <wchar.h>
48 #endif
49
50 /* Include the original <wctype.h> if it exists.
51    BeOS 5 has the functions but no <wctype.h>.  */
52 /* The include_next requires a split double-inclusion guard.  */
53 #if @HAVE_WCTYPE_H@
54 # @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
55 #endif
56
57 #ifndef _@GUARD_PREFIX@_WCTYPE_H
58 #define _@GUARD_PREFIX@_WCTYPE_H
59
60 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
61
62 /* The definition of _GL_WARN_ON_USE is copied here.  */
63
64 /* Solaris 2.6 <wctype.h> includes <widec.h> which includes <euc.h> which
65    #defines a number of identifiers in the application namespace.  Revert
66    these #defines.  */
67 #ifdef __sun
68 # undef multibyte
69 # undef eucw1
70 # undef eucw2
71 # undef eucw3
72 # undef scrw1
73 # undef scrw2
74 # undef scrw3
75 #endif
76
77 /* Define wint_t and WEOF.  (Also done in wchar.in.h.)  */
78 #if !@HAVE_WINT_T@ && !defined wint_t
79 # define wint_t int
80 # ifndef WEOF
81 #  define WEOF -1
82 # endif
83 #else
84 # ifndef WEOF
85 #  define WEOF ((wint_t) -1)
86 # endif
87 #endif
88
89
90 #if !GNULIB_defined_wctype_functions
91
92 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
93    Linux libc5 has <wctype.h> and the functions but they are broken.
94    Assume all 11 functions (all isw* except iswblank) are implemented the
95    same way, or not at all.  */
96 # if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
97
98 /* IRIX 5.3 has macros but no functions, its isw* macros refer to an
99    undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
100    refer to system functions like _iswctype that are not in the
101    standard C library.  Rather than try to get ancient buggy
102    implementations like this to work, just disable them.  */
103 #  undef iswalnum
104 #  undef iswalpha
105 #  undef iswblank
106 #  undef iswcntrl
107 #  undef iswdigit
108 #  undef iswgraph
109 #  undef iswlower
110 #  undef iswprint
111 #  undef iswpunct
112 #  undef iswspace
113 #  undef iswupper
114 #  undef iswxdigit
115 #  undef towlower
116 #  undef towupper
117
118 /* Linux libc5 has <wctype.h> and the functions but they are broken.  */
119 #  if @REPLACE_ISWCNTRL@
120 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
121 #    define iswalnum rpl_iswalnum
122 #    define iswalpha rpl_iswalpha
123 #    define iswblank rpl_iswblank
124 #    define iswcntrl rpl_iswcntrl
125 #    define iswdigit rpl_iswdigit
126 #    define iswgraph rpl_iswgraph
127 #    define iswlower rpl_iswlower
128 #    define iswprint rpl_iswprint
129 #    define iswpunct rpl_iswpunct
130 #    define iswspace rpl_iswspace
131 #    define iswupper rpl_iswupper
132 #    define iswxdigit rpl_iswxdigit
133 #    define towlower rpl_towlower
134 #    define towupper rpl_towupper
135 #   endif
136 #  endif
137
138 static inline int
139 #  if @REPLACE_ISWCNTRL@
140 rpl_iswalnum
141 #  else
142 iswalnum
143 #  endif
144          (wint_t wc)
145 {
146   return ((wc >= '0' && wc <= '9')
147           || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
148 }
149
150 static inline int
151 #  if @REPLACE_ISWCNTRL@
152 rpl_iswalpha
153 #  else
154 iswalpha
155 #  endif
156          (wint_t wc)
157 {
158   return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
159 }
160
161 static inline int
162 #  if @REPLACE_ISWCNTRL@
163 rpl_iswblank
164 #  else
165 iswblank
166 #  endif
167          (wint_t wc)
168 {
169   return wc == ' ' || wc == '\t';
170 }
171
172 static inline int
173 #  if @REPLACE_ISWCNTRL@
174 rpl_iswcntrl
175 #  else
176 iswcntrl
177 #  endif
178         (wint_t wc)
179 {
180   return (wc & ~0x1f) == 0 || wc == 0x7f;
181 }
182
183 static inline int
184 #  if @REPLACE_ISWCNTRL@
185 rpl_iswdigit
186 #  else
187 iswdigit
188 #  endif
189          (wint_t wc)
190 {
191   return wc >= '0' && wc <= '9';
192 }
193
194 static inline int
195 #  if @REPLACE_ISWCNTRL@
196 rpl_iswgraph
197 #  else
198 iswgraph
199 #  endif
200          (wint_t wc)
201 {
202   return wc >= '!' && wc <= '~';
203 }
204
205 static inline int
206 #  if @REPLACE_ISWCNTRL@
207 rpl_iswlower
208 #  else
209 iswlower
210 #  endif
211          (wint_t wc)
212 {
213   return wc >= 'a' && wc <= 'z';
214 }
215
216 static inline int
217 #  if @REPLACE_ISWCNTRL@
218 rpl_iswprint
219 #  else
220 iswprint
221 #  endif
222          (wint_t wc)
223 {
224   return wc >= ' ' && wc <= '~';
225 }
226
227 static inline int
228 #  if @REPLACE_ISWCNTRL@
229 rpl_iswpunct
230 #  else
231 iswpunct
232 #  endif
233          (wint_t wc)
234 {
235   return (wc >= '!' && wc <= '~'
236           && !((wc >= '0' && wc <= '9')
237                || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
238 }
239
240 static inline int
241 #  if @REPLACE_ISWCNTRL@
242 rpl_iswspace
243 #  else
244 iswspace
245 #  endif
246          (wint_t wc)
247 {
248   return (wc == ' ' || wc == '\t'
249           || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
250 }
251
252 static inline int
253 #  if @REPLACE_ISWCNTRL@
254 rpl_iswupper
255 #  else
256 iswupper
257 #  endif
258          (wint_t wc)
259 {
260   return wc >= 'A' && wc <= 'Z';
261 }
262
263 static inline int
264 #  if @REPLACE_ISWCNTRL@
265 rpl_iswxdigit
266 #  else
267 iswxdigit
268 #  endif
269           (wint_t wc)
270 {
271   return ((wc >= '0' && wc <= '9')
272           || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
273 }
274
275 static inline wint_t
276 #  if @REPLACE_ISWCNTRL@
277 rpl_towlower
278 #  else
279 towlower
280 #  endif
281          (wint_t wc)
282 {
283   return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
284 }
285
286 static inline wint_t
287 #  if @REPLACE_ISWCNTRL@
288 rpl_towupper
289 #  else
290 towupper
291 #  endif
292          (wint_t wc)
293 {
294   return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
295 }
296
297 # elif @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@)
298 /* Only the iswblank function is missing.  */
299
300 #  if @REPLACE_ISWBLANK@
301 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
302 #    define iswblank rpl_iswblank
303 #   endif
304 _GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
305 #  else
306 _GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
307 #  endif
308
309 # endif
310
311 # if defined __MINGW32__
312
313 /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
314    The functions towlower and towupper are implemented in the MSVCRT library
315    to take a wchar_t argument and return a wchar_t result.  mingw declares
316    these functions to take a wint_t argument and return a wint_t result.
317    This means that:
318    1. When the user passes an argument outside the range 0x0000..0xFFFF, the
319       function will look only at the lower 16 bits.  This is allowed according
320       to POSIX.
321    2. The return value is returned in the lower 16 bits of the result register.
322       The upper 16 bits are random: whatever happened to be in that part of the
323       result register.  We need to fix this by adding a zero-extend from
324       wchar_t to wint_t after the call.  */
325
326 static inline wint_t
327 rpl_towlower (wint_t wc)
328 {
329   return (wint_t) (wchar_t) towlower (wc);
330 }
331 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
332 #   define towlower rpl_towlower
333 #  endif
334
335 static inline wint_t
336 rpl_towupper (wint_t wc)
337 {
338   return (wint_t) (wchar_t) towupper (wc);
339 }
340 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
341 #   define towupper rpl_towupper
342 #  endif
343
344 # endif /* __MINGW32__ */
345
346 # define GNULIB_defined_wctype_functions 1
347 #endif
348
349 #if @REPLACE_ISWCNTRL@
350 _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
351 _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
352 _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
353 _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
354 _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
355 _GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
356 _GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
357 _GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
358 _GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
359 _GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
360 _GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
361 #else
362 _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
363 _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
364 _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
365 _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
366 _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
367 _GL_CXXALIAS_SYS (iswlower, int, (wint_t wc));
368 _GL_CXXALIAS_SYS (iswprint, int, (wint_t wc));
369 _GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc));
370 _GL_CXXALIAS_SYS (iswspace, int, (wint_t wc));
371 _GL_CXXALIAS_SYS (iswupper, int, (wint_t wc));
372 _GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
373 #endif
374 _GL_CXXALIASWARN (iswalnum);
375 _GL_CXXALIASWARN (iswalpha);
376 _GL_CXXALIASWARN (iswcntrl);
377 _GL_CXXALIASWARN (iswdigit);
378 _GL_CXXALIASWARN (iswgraph);
379 _GL_CXXALIASWARN (iswlower);
380 _GL_CXXALIASWARN (iswprint);
381 _GL_CXXALIASWARN (iswpunct);
382 _GL_CXXALIASWARN (iswspace);
383 _GL_CXXALIASWARN (iswupper);
384 _GL_CXXALIASWARN (iswxdigit);
385
386 #if @GNULIB_ISWBLANK@
387 # if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@
388 _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
389 # else
390 _GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
391 # endif
392 _GL_CXXALIASWARN (iswblank);
393 #endif
394
395 #if !@HAVE_WCTYPE_T@
396 # if !GNULIB_defined_wctype_t
397 typedef void * wctype_t;
398 #  define GNULIB_defined_wctype_t 1
399 # endif
400 #endif
401
402 /* Get a descriptor for a wide character property.  */
403 #if @GNULIB_WCTYPE@
404 # if !@HAVE_WCTYPE_T@
405 _GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name));
406 # endif
407 _GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
408 _GL_CXXALIASWARN (wctype);
409 #elif defined GNULIB_POSIXCHECK
410 # undef wctype
411 # if HAVE_RAW_DECL_WCTYPE
412 _GL_WARN_ON_USE (wctype, "wctype is unportable - "
413                  "use gnulib module wctype for portability");
414 # endif
415 #endif
416
417 /* Test whether a wide character has a given property.
418    The argument WC must be either a wchar_t value or WEOF.
419    The argument DESC must have been returned by the wctype() function.  */
420 #if @GNULIB_ISWCTYPE@
421 # if !@HAVE_WCTYPE_T@
422 _GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc));
423 # endif
424 _GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
425 _GL_CXXALIASWARN (iswctype);
426 #elif defined GNULIB_POSIXCHECK
427 # undef iswctype
428 # if HAVE_RAW_DECL_ISWCTYPE
429 _GL_WARN_ON_USE (iswctype, "iswctype is unportable - "
430                  "use gnulib module iswctype for portability");
431 # endif
432 #endif
433
434 #if @REPLACE_ISWCNTRL@ || defined __MINGW32__
435 _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
436 _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
437 #else
438 _GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc));
439 _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
440 #endif
441 _GL_CXXALIASWARN (towlower);
442 _GL_CXXALIASWARN (towupper);
443
444 #if !@HAVE_WCTRANS_T@
445 # if !GNULIB_defined_wctrans_t
446 typedef void * wctrans_t;
447 #  define GNULIB_defined_wctrans_t 1
448 # endif
449 #endif
450
451 /* Get a descriptor for a wide character case conversion.  */
452 #if @GNULIB_WCTRANS@
453 # if !@HAVE_WCTRANS_T@
454 _GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name));
455 # endif
456 _GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
457 _GL_CXXALIASWARN (wctrans);
458 #elif defined GNULIB_POSIXCHECK
459 # undef wctrans
460 # if HAVE_RAW_DECL_WCTRANS
461 _GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
462                  "use gnulib module wctrans for portability");
463 # endif
464 #endif
465
466 /* Perform a given case conversion on a wide character.
467    The argument WC must be either a wchar_t value or WEOF.
468    The argument DESC must have been returned by the wctrans() function.  */
469 #if @GNULIB_TOWCTRANS@
470 # if !@HAVE_WCTRANS_T@
471 _GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
472 # endif
473 _GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
474 _GL_CXXALIASWARN (towctrans);
475 #elif defined GNULIB_POSIXCHECK
476 # undef towctrans
477 # if HAVE_RAW_DECL_TOWCTRANS
478 _GL_WARN_ON_USE (towctrans, "towctrans is unportable - "
479                  "use gnulib module towctrans for portability");
480 # endif
481 #endif
482
483
484 #endif /* _@GUARD_PREFIX@_WCTYPE_H */
485 #endif /* _@GUARD_PREFIX@_WCTYPE_H */