1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
3 
4    Copyright (C) 2006-2020 Free Software Foundation, Inc.
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3, or (at your option)
9    any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, see <https://www.gnu.org/licenses/>.  */
18 
19 /* Written by Bruno Haible and Paul Eggert.  */
20 
21 /*
22  * ISO C 99 <wctype.h> for platforms that lack it.
23  * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wctype.h.html>
24  *
25  * iswctype, towctrans, towlower, towupper, wctrans, wctype,
26  * wctrans_t, and wctype_t are not yet implemented.
27  */
28 
29 #if __GNUC__ >= 3
30 #pragma GCC system_header
31 #endif
32 
33 
34 #if (defined __MINGW32__ && defined __CTYPE_H_SOURCED__)
35 
36 /* Special invocation convention:
37    - With MinGW 3.22, when <ctype.h> includes <wctype.h>, only some part of
38      <wctype.h> is being processed, which doesn't include the idempotency
39      guard.   */
40 
41 #include_next <wctype.h>
42 
43 #else
44 /* Normal invocation convention.  */
45 
46 #ifndef _GL_WCTYPE_H
47 
48 #if 1
49 /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
50    Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
51    <wchar.h>.
52    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
53    included before <wchar.h>.  */
54 # include <stddef.h>
55 # include <stdio.h>
56 # include <time.h>
57 # include <wchar.h>
58 #endif
59 
60 /* Native Windows (mingw, MSVC) have declarations of towupper, towlower, and
61    isw* functions in <ctype.h>, <wchar.h> as well as in <wctype.h>.  Include
62    <ctype.h>, <wchar.h> in advance to avoid rpl_ prefix being added to the
63    declarations.  */
64 #if defined _WIN32 && ! defined __CYGWIN__
65 # include <ctype.h>
66 # include <wchar.h>
67 #endif
68 
69 /* Include the original <wctype.h> if it exists.
70    BeOS 5 has the functions but no <wctype.h>.  */
71 /* The include_next requires a split double-inclusion guard.  */
72 #if 1
73 # include_next <wctype.h>
74 #endif
75 
76 #ifndef _GL_WCTYPE_H
77 #define _GL_WCTYPE_H
78 
79 #ifndef _GL_INLINE_HEADER_BEGIN
80  #error "Please include config.h first."
81 #endif
82 _GL_INLINE_HEADER_BEGIN
83 #ifndef _GL_WCTYPE_INLINE
84 # define _GL_WCTYPE_INLINE _GL_INLINE
85 #endif
86 
87 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
88 /* C++ compatible function declaration macros.
89    Copyright (C) 2010-2020 Free Software Foundation, Inc.
90 
91    This program is free software: you can redistribute it and/or modify it
92    under the terms of the GNU General Public License as published
93    by the Free Software Foundation; either version 3 of the License, or
94    (at your option) any later version.
95 
96    This program is distributed in the hope that it will be useful,
97    but WITHOUT ANY WARRANTY; without even the implied warranty of
98    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
99    General Public License for more details.
100 
101    You should have received a copy of the GNU General Public License
102    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
103 
104 #ifndef _GL_CXXDEFS_H
105 #define _GL_CXXDEFS_H
106 
107 /* Begin/end the GNULIB_NAMESPACE namespace.  */
108 #if defined __cplusplus && defined GNULIB_NAMESPACE
109 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
110 # define _GL_END_NAMESPACE }
111 #else
112 # define _GL_BEGIN_NAMESPACE
113 # define _GL_END_NAMESPACE
114 #endif
115 
116 /* The three most frequent use cases of these macros are:
117 
118    * For providing a substitute for a function that is missing on some
119      platforms, but is declared and works fine on the platforms on which
120      it exists:
121 
122        #if @GNULIB_FOO@
123        # if !@HAVE_FOO@
124        _GL_FUNCDECL_SYS (foo, ...);
125        # endif
126        _GL_CXXALIAS_SYS (foo, ...);
127        _GL_CXXALIASWARN (foo);
128        #elif defined GNULIB_POSIXCHECK
129        ...
130        #endif
131 
132    * For providing a replacement for a function that exists on all platforms,
133      but is broken/insufficient and needs to be replaced on some platforms:
134 
135        #if @GNULIB_FOO@
136        # if @REPLACE_FOO@
137        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
138        #   undef foo
139        #   define foo rpl_foo
140        #  endif
141        _GL_FUNCDECL_RPL (foo, ...);
142        _GL_CXXALIAS_RPL (foo, ...);
143        # else
144        _GL_CXXALIAS_SYS (foo, ...);
145        # endif
146        _GL_CXXALIASWARN (foo);
147        #elif defined GNULIB_POSIXCHECK
148        ...
149        #endif
150 
151    * For providing a replacement for a function that exists on some platforms
152      but is broken/insufficient and needs to be replaced on some of them and
153      is additionally either missing or undeclared on some other platforms:
154 
155        #if @GNULIB_FOO@
156        # if @REPLACE_FOO@
157        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
158        #   undef foo
159        #   define foo rpl_foo
160        #  endif
161        _GL_FUNCDECL_RPL (foo, ...);
162        _GL_CXXALIAS_RPL (foo, ...);
163        # else
164        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
165        _GL_FUNCDECL_SYS (foo, ...);
166        #  endif
167        _GL_CXXALIAS_SYS (foo, ...);
168        # endif
169        _GL_CXXALIASWARN (foo);
170        #elif defined GNULIB_POSIXCHECK
171        ...
172        #endif
173 */
174 
175 /* _GL_EXTERN_C declaration;
176    performs the declaration with C linkage.  */
177 #if defined __cplusplus
178 # define _GL_EXTERN_C extern "C"
179 #else
180 # define _GL_EXTERN_C extern
181 #endif
182 
183 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
184    declares a replacement function, named rpl_func, with the given prototype,
185    consisting of return type, parameters, and attributes.
186    Example:
187      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
188                                   _GL_ARG_NONNULL ((1)));
189  */
190 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
191   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
192 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
193   _GL_EXTERN_C rettype rpl_func parameters_and_attributes
194 
195 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
196    declares the system function, named func, with the given prototype,
197    consisting of return type, parameters, and attributes.
198    Example:
199      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
200                                   _GL_ARG_NONNULL ((1)));
201  */
202 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
203   _GL_EXTERN_C rettype func parameters_and_attributes
204 
205 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
206    declares a C++ alias called GNULIB_NAMESPACE::func
207    that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
208    Example:
209      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
210 
211    Wrapping rpl_func in an object with an inline conversion operator
212    avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
213    actually used in the program.  */
214 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
215   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
216 #if defined __cplusplus && defined GNULIB_NAMESPACE
217 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
218     namespace GNULIB_NAMESPACE                                \
219     {                                                         \
220       static const struct _gl_ ## func ## _wrapper            \
221       {                                                       \
222         typedef rettype (*type) parameters;                   \
223                                                               \
224         inline operator type () const                         \
225         {                                                     \
226           return ::rpl_func;                                  \
227         }                                                     \
228       } func = {};                                            \
229     }                                                         \
230     _GL_EXTERN_C int _gl_cxxalias_dummy
231 #else
232 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
233     _GL_EXTERN_C int _gl_cxxalias_dummy
234 #endif
235 
236 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
237    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
238    except that the C function rpl_func may have a slightly different
239    declaration.  A cast is used to silence the "invalid conversion" error
240    that would otherwise occur.  */
241 #if defined __cplusplus && defined GNULIB_NAMESPACE
242 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
243     namespace GNULIB_NAMESPACE                                     \
244     {                                                              \
245       static const struct _gl_ ## func ## _wrapper                 \
246       {                                                            \
247         typedef rettype (*type) parameters;                        \
248                                                                    \
249         inline operator type () const                              \
250         {                                                          \
251           return reinterpret_cast<type>(::rpl_func);               \
252         }                                                          \
253       } func = {};                                                 \
254     }                                                              \
255     _GL_EXTERN_C int _gl_cxxalias_dummy
256 #else
257 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
258     _GL_EXTERN_C int _gl_cxxalias_dummy
259 #endif
260 
261 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
262    declares a C++ alias called GNULIB_NAMESPACE::func
263    that redirects to the system provided function func, if GNULIB_NAMESPACE
264    is defined.
265    Example:
266      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
267 
268    Wrapping func in an object with an inline conversion operator
269    avoids a reference to func unless GNULIB_NAMESPACE::func is
270    actually used in the program.  */
271 #if defined __cplusplus && defined GNULIB_NAMESPACE
272 # define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
273     namespace GNULIB_NAMESPACE                                \
274     {                                                         \
275       static const struct _gl_ ## func ## _wrapper            \
276       {                                                       \
277         typedef rettype (*type) parameters;                   \
278                                                               \
279         inline operator type () const                         \
280         {                                                     \
281           return ::func;                                      \
282         }                                                     \
283       } func = {};                                            \
284     }                                                         \
285     _GL_EXTERN_C int _gl_cxxalias_dummy
286 #else
287 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
288     _GL_EXTERN_C int _gl_cxxalias_dummy
289 #endif
290 
291 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
292    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
293    except that the C function func may have a slightly different declaration.
294    A cast is used to silence the "invalid conversion" error that would
295    otherwise occur.  */
296 #if defined __cplusplus && defined GNULIB_NAMESPACE
297 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
298     namespace GNULIB_NAMESPACE                          \
299     {                                                   \
300       static const struct _gl_ ## func ## _wrapper      \
301       {                                                 \
302         typedef rettype (*type) parameters;             \
303                                                         \
304         inline operator type () const                   \
305         {                                               \
306           return reinterpret_cast<type>(::func);        \
307         }                                               \
308       } func = {};                                      \
309     }                                                   \
310     _GL_EXTERN_C int _gl_cxxalias_dummy
311 #else
312 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
313     _GL_EXTERN_C int _gl_cxxalias_dummy
314 #endif
315 
316 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
317    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
318    except that the C function is picked among a set of overloaded functions,
319    namely the one with rettype2 and parameters2.  Two consecutive casts
320    are used to silence the "cannot find a match" and "invalid conversion"
321    errors that would otherwise occur.  */
322 #if defined __cplusplus && defined GNULIB_NAMESPACE
323   /* The outer cast must be a reinterpret_cast.
324      The inner cast: When the function is defined as a set of overloaded
325      functions, it works as a static_cast<>, choosing the designated variant.
326      When the function is defined as a single variant, it works as a
327      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
328 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
329     namespace GNULIB_NAMESPACE                                                \
330     {                                                                         \
331       static const struct _gl_ ## func ## _wrapper                            \
332       {                                                                       \
333         typedef rettype (*type) parameters;                                   \
334                                                                               \
335         inline operator type () const                                         \
336         {                                                                     \
337           return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
338         }                                                                     \
339       } func = {};                                                            \
340     }                                                                         \
341     _GL_EXTERN_C int _gl_cxxalias_dummy
342 #else
343 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
344     _GL_EXTERN_C int _gl_cxxalias_dummy
345 #endif
346 
347 /* _GL_CXXALIASWARN (func);
348    causes a warning to be emitted when ::func is used but not when
349    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
350    variants.  */
351 #if defined __cplusplus && defined GNULIB_NAMESPACE
352 # define _GL_CXXALIASWARN(func) \
353    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
354 # define _GL_CXXALIASWARN_1(func,namespace) \
355    _GL_CXXALIASWARN_2 (func, namespace)
356 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
357    we enable the warning only when not optimizing.  */
358 # if !__OPTIMIZE__
359 #  define _GL_CXXALIASWARN_2(func,namespace) \
360     _GL_WARN_ON_USE (func, \
361                      "The symbol ::" #func " refers to the system function. " \
362                      "Use " #namespace "::" #func " instead.")
363 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
364 #  define _GL_CXXALIASWARN_2(func,namespace) \
365      extern __typeof__ (func) func
366 # else
367 #  define _GL_CXXALIASWARN_2(func,namespace) \
368      _GL_EXTERN_C int _gl_cxxalias_dummy
369 # endif
370 #else
371 # define _GL_CXXALIASWARN(func) \
372     _GL_EXTERN_C int _gl_cxxalias_dummy
373 #endif
374 
375 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
376    causes a warning to be emitted when the given overloaded variant of ::func
377    is used but not when GNULIB_NAMESPACE::func is used.  */
378 #if defined __cplusplus && defined GNULIB_NAMESPACE
379 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
380    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
381                         GNULIB_NAMESPACE)
382 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
383    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
384 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
385    we enable the warning only when not optimizing.  */
386 # if !__OPTIMIZE__
387 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
388     _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
389                          "The symbol ::" #func " refers to the system function. " \
390                          "Use " #namespace "::" #func " instead.")
391 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
392 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
393      extern __typeof__ (func) func
394 # else
395 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
396      _GL_EXTERN_C int _gl_cxxalias_dummy
397 # endif
398 #else
399 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
400     _GL_EXTERN_C int _gl_cxxalias_dummy
401 #endif
402 
403 #endif /* _GL_CXXDEFS_H */
404 
405 /* The definition of _GL_WARN_ON_USE is copied here.  */
406 /* A C macro for emitting warnings if a function is used.
407    Copyright (C) 2010-2020 Free Software Foundation, Inc.
408 
409    This program is free software: you can redistribute it and/or modify it
410    under the terms of the GNU General Public License as published
411    by the Free Software Foundation; either version 3 of the License, or
412    (at your option) any later version.
413 
414    This program is distributed in the hope that it will be useful,
415    but WITHOUT ANY WARRANTY; without even the implied warranty of
416    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
417    General Public License for more details.
418 
419    You should have received a copy of the GNU General Public License
420    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
421 
422 /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
423    for FUNCTION which will then trigger a compiler warning containing
424    the text of "literal string" anywhere that function is called, if
425    supported by the compiler.  If the compiler does not support this
426    feature, the macro expands to an unused extern declaration.
427 
428    _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
429    attribute used in _GL_WARN_ON_USE.  If the compiler does not support
430    this feature, it expands to empty.
431 
432    These macros are useful for marking a function as a potential
433    portability trap, with the intent that "literal string" include
434    instructions on the replacement function that should be used
435    instead.
436    _GL_WARN_ON_USE is for functions with 'extern' linkage.
437    _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
438    linkage.
439 
440    However, one of the reasons that a function is a portability trap is
441    if it has the wrong signature.  Declaring FUNCTION with a different
442    signature in C is a compilation error, so this macro must use the
443    same type as any existing declaration so that programs that avoid
444    the problematic FUNCTION do not fail to compile merely because they
445    included a header that poisoned the function.  But this implies that
446    _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
447    have a declaration.  Use of this macro implies that there must not
448    be any other macro hiding the declaration of FUNCTION; but
449    undefining FUNCTION first is part of the poisoning process anyway
450    (although for symbols that are provided only via a macro, the result
451    is a compilation error rather than a warning containing
452    "literal string").  Also note that in C++, it is only safe to use if
453    FUNCTION has no overloads.
454 
455    For an example, it is possible to poison 'getline' by:
456    - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
457      [getline]) in configure.ac, which potentially defines
458      HAVE_RAW_DECL_GETLINE
459    - adding this code to a header that wraps the system <stdio.h>:
460      #undef getline
461      #if HAVE_RAW_DECL_GETLINE
462      _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
463        "not universally present; use the gnulib module getline");
464      #endif
465 
466    It is not possible to directly poison global variables.  But it is
467    possible to write a wrapper accessor function, and poison that
468    (less common usage, like &environ, will cause a compilation error
469    rather than issue the nice warning, but the end result of informing
470    the developer about their portability problem is still achieved):
471      #if HAVE_RAW_DECL_ENVIRON
472      static char ***
473      rpl_environ (void) { return &environ; }
474      _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
475      # undef environ
476      # define environ (*rpl_environ ())
477      #endif
478    or better (avoiding contradictory use of 'static' and 'extern'):
479      #if HAVE_RAW_DECL_ENVIRON
480      static char ***
481      _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
482      rpl_environ (void) { return &environ; }
483      # undef environ
484      # define environ (*rpl_environ ())
485      #endif
486    */
487 #ifndef _GL_WARN_ON_USE
488 
489 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
490 /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
491 #  define _GL_WARN_ON_USE(function, message) \
492 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
493 #  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
494   __attribute__ ((__warning__ (message)))
495 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
496 /* Verify the existence of the function.  */
497 #  define _GL_WARN_ON_USE(function, message) \
498 extern __typeof__ (function) function
499 #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
500 # else /* Unsupported.  */
501 #  define _GL_WARN_ON_USE(function, message) \
502 _GL_WARN_EXTERN_C int _gl_warn_on_use
503 #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
504 # endif
505 #endif
506 
507 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
508    is like _GL_WARN_ON_USE (function, "string"), except that the function is
509    declared with the given prototype, consisting of return type, parameters,
510    and attributes.
511    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
512    not work in this case.  */
513 #ifndef _GL_WARN_ON_USE_CXX
514 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
515 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
516 extern rettype function parameters_and_attributes \
517      __attribute__ ((__warning__ (msg)))
518 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
519 /* Verify the existence of the function.  */
520 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
521 extern rettype function parameters_and_attributes
522 # else /* Unsupported.  */
523 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
524 _GL_WARN_EXTERN_C int _gl_warn_on_use
525 # endif
526 #endif
527 
528 /* _GL_WARN_EXTERN_C declaration;
529    performs the declaration with C linkage.  */
530 #ifndef _GL_WARN_EXTERN_C
531 # if defined __cplusplus
532 #  define _GL_WARN_EXTERN_C extern "C"
533 # else
534 #  define _GL_WARN_EXTERN_C extern
535 # endif
536 #endif
537 
538 /* Solaris 2.6 <wctype.h> includes <widec.h> which includes <euc.h> which
539    #defines a number of identifiers in the application namespace.  Revert
540    these #defines.  */
541 #ifdef __sun
542 # undef multibyte
543 # undef eucw1
544 # undef eucw2
545 # undef eucw3
546 # undef scrw1
547 # undef scrw2
548 # undef scrw3
549 #endif
550 
551 /* Define wint_t and WEOF.  (Also done in wchar.in.h.)  */
552 #if !1 && !defined wint_t
553 # define wint_t int
554 # ifndef WEOF
555 #  define WEOF -1
556 # endif
557 #else
558 /* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
559    <stddef.h>.  This is too small: ISO C 99 section 7.24.1.(2) says that
560    wint_t must be "unchanged by default argument promotions".  Override it.  */
561 # if 0
562 #  if !GNULIB_defined_wint_t
563 #   if 0
564 #    include <crtdefs.h>
565 #   else
566 #    include <stddef.h>
567 #   endif
568 typedef unsigned int rpl_wint_t;
569 #   undef wint_t
570 #   define wint_t rpl_wint_t
571 #   define GNULIB_defined_wint_t 1
572 #  endif
573 # endif
574 # ifndef WEOF
575 #  define WEOF ((wint_t) -1)
576 # endif
577 #endif
578 
579 
580 #if !GNULIB_defined_wctype_functions
581 
582 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
583    Linux libc5 has <wctype.h> and the functions but they are broken.
584    mingw and MSVC have <wctype.h> and the functions but they take a wchar_t
585    as argument, not an rpl_wint_t.
586    Assume all 11 functions (all isw* except iswblank) are implemented the
587    same way, or not at all.  */
588 # if ! 1 || 0
589 
590 #  if 0 /* implies 0 */
591 
592 _GL_WCTYPE_INLINE int
593 rpl_iswalnum (wint_t wc)
594 {
595   return ((wchar_t) wc == wc ? iswalnum ((wchar_t) wc) : 0);
596 }
597 
598 _GL_WCTYPE_INLINE int
599 rpl_iswalpha (wint_t wc)
600 {
601   return ((wchar_t) wc == wc ? iswalpha ((wchar_t) wc) : 0);
602 }
603 
604 _GL_WCTYPE_INLINE int
605 rpl_iswblank (wint_t wc)
606 {
607   return ((wchar_t) wc == wc ? iswblank ((wchar_t) wc) : 0);
608 }
609 
610 _GL_WCTYPE_INLINE int
611 rpl_iswcntrl (wint_t wc)
612 {
613   return ((wchar_t) wc == wc ? iswcntrl ((wchar_t) wc) : 0);
614 }
615 
616 _GL_WCTYPE_INLINE int
617 rpl_iswdigit (wint_t wc)
618 {
619   return ((wchar_t) wc == wc ? iswdigit ((wchar_t) wc) : 0);
620 }
621 
622 _GL_WCTYPE_INLINE int
623 rpl_iswgraph (wint_t wc)
624 {
625   return ((wchar_t) wc == wc ? iswgraph ((wchar_t) wc) : 0);
626 }
627 
628 _GL_WCTYPE_INLINE int
629 rpl_iswlower (wint_t wc)
630 {
631   return ((wchar_t) wc == wc ? iswlower ((wchar_t) wc) : 0);
632 }
633 
634 _GL_WCTYPE_INLINE int
635 rpl_iswprint (wint_t wc)
636 {
637   return ((wchar_t) wc == wc ? iswprint ((wchar_t) wc) : 0);
638 }
639 
640 _GL_WCTYPE_INLINE int
641 rpl_iswpunct (wint_t wc)
642 {
643   return ((wchar_t) wc == wc ? iswpunct ((wchar_t) wc) : 0);
644 }
645 
646 _GL_WCTYPE_INLINE int
647 rpl_iswspace (wint_t wc)
648 {
649   return ((wchar_t) wc == wc ? iswspace ((wchar_t) wc) : 0);
650 }
651 
652 _GL_WCTYPE_INLINE int
653 rpl_iswupper (wint_t wc)
654 {
655   return ((wchar_t) wc == wc ? iswupper ((wchar_t) wc) : 0);
656 }
657 
658 _GL_WCTYPE_INLINE int
659 rpl_iswxdigit (wint_t wc)
660 {
661   return ((wchar_t) wc == wc ? iswxdigit ((wchar_t) wc) : 0);
662 }
663 
664 _GL_WCTYPE_INLINE wint_t
665 rpl_towlower (wint_t wc)
666 {
667   return ((wchar_t) wc == wc ? (wchar_t) towlower ((wchar_t) wc) : wc);
668 }
669 
670 _GL_WCTYPE_INLINE wint_t
671 rpl_towupper (wint_t wc)
672 {
673   return ((wchar_t) wc == wc ? (wchar_t) towupper ((wchar_t) wc) : wc);
674 }
675 
676 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
677 #    undef iswalnum
678 #    undef iswalpha
679 #    undef iswblank
680 #    undef iswcntrl
681 #    undef iswdigit
682 #    undef iswgraph
683 #    undef iswlower
684 #    undef iswprint
685 #    undef iswpunct
686 #    undef iswspace
687 #    undef iswupper
688 #    undef iswxdigit
689 #    undef towlower
690 #    undef towupper
691 #    define iswalnum rpl_iswalnum
692 #    define iswalpha rpl_iswalpha
693 #    define iswblank rpl_iswblank
694 #    define iswcntrl rpl_iswcntrl
695 #    define iswdigit rpl_iswdigit
696 #    define iswgraph rpl_iswgraph
697 #    define iswlower rpl_iswlower
698 #    define iswprint rpl_iswprint
699 #    define iswpunct rpl_iswpunct
700 #    define iswspace rpl_iswspace
701 #    define iswupper rpl_iswupper
702 #    define iswxdigit rpl_iswxdigit
703 #    define towlower rpl_towlower
704 #    define towupper rpl_towupper
705 #   endif
706 
707 #  else
708 
709 /* IRIX 5.3 has macros but no functions, its isw* macros refer to an
710    undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
711    refer to system functions like _iswctype that are not in the
712    standard C library.  Rather than try to get ancient buggy
713    implementations like this to work, just disable them.  */
714 #   undef iswalnum
715 #   undef iswalpha
716 #   undef iswblank
717 #   undef iswcntrl
718 #   undef iswdigit
719 #   undef iswgraph
720 #   undef iswlower
721 #   undef iswprint
722 #   undef iswpunct
723 #   undef iswspace
724 #   undef iswupper
725 #   undef iswxdigit
726 #   undef towlower
727 #   undef towupper
728 
729 /* Linux libc5 has <wctype.h> and the functions but they are broken.  */
730 #   if 0
731 #    if !(defined __cplusplus && defined GNULIB_NAMESPACE)
732 #     define iswalnum rpl_iswalnum
733 #     define iswalpha rpl_iswalpha
734 #     define iswblank rpl_iswblank
735 #     define iswcntrl rpl_iswcntrl
736 #     define iswdigit rpl_iswdigit
737 #     define iswgraph rpl_iswgraph
738 #     define iswlower rpl_iswlower
739 #     define iswprint rpl_iswprint
740 #     define iswpunct rpl_iswpunct
741 #     define iswspace rpl_iswspace
742 #     define iswupper rpl_iswupper
743 #     define iswxdigit rpl_iswxdigit
744 #    endif
745 #   endif
746 #   if 0
747 #    if !(defined __cplusplus && defined GNULIB_NAMESPACE)
748 #     define towlower rpl_towlower
749 #     define towupper rpl_towupper
750 #    endif
751 #   endif
752 
753 _GL_WCTYPE_INLINE int
754 #   if 0
755 rpl_iswalnum
756 #   else
757 iswalnum
758 #   endif
759          (wint_t wc)
760 {
761   return ((wc >= '0' && wc <= '9')
762           || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
763 }
764 
765 _GL_WCTYPE_INLINE int
766 #   if 0
767 rpl_iswalpha
768 #   else
769 iswalpha
770 #   endif
771          (wint_t wc)
772 {
773   return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
774 }
775 
776 _GL_WCTYPE_INLINE int
777 #   if 0
778 rpl_iswblank
779 #   else
780 iswblank
781 #   endif
782          (wint_t wc)
783 {
784   return wc == ' ' || wc == '\t';
785 }
786 
787 _GL_WCTYPE_INLINE int
788 #   if 0
789 rpl_iswcntrl
790 #   else
791 iswcntrl
792 #   endif
793         (wint_t wc)
794 {
795   return (wc & ~0x1f) == 0 || wc == 0x7f;
796 }
797 
798 _GL_WCTYPE_INLINE int
799 #   if 0
800 rpl_iswdigit
801 #   else
802 iswdigit
803 #   endif
804          (wint_t wc)
805 {
806   return wc >= '0' && wc <= '9';
807 }
808 
809 _GL_WCTYPE_INLINE int
810 #   if 0
811 rpl_iswgraph
812 #   else
813 iswgraph
814 #   endif
815          (wint_t wc)
816 {
817   return wc >= '!' && wc <= '~';
818 }
819 
820 _GL_WCTYPE_INLINE int
821 #   if 0
822 rpl_iswlower
823 #   else
824 iswlower
825 #   endif
826          (wint_t wc)
827 {
828   return wc >= 'a' && wc <= 'z';
829 }
830 
831 _GL_WCTYPE_INLINE int
832 #   if 0
833 rpl_iswprint
834 #   else
835 iswprint
836 #   endif
837          (wint_t wc)
838 {
839   return wc >= ' ' && wc <= '~';
840 }
841 
842 _GL_WCTYPE_INLINE int
843 #   if 0
844 rpl_iswpunct
845 #   else
846 iswpunct
847 #   endif
848          (wint_t wc)
849 {
850   return (wc >= '!' && wc <= '~'
851           && !((wc >= '0' && wc <= '9')
852                || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
853 }
854 
855 _GL_WCTYPE_INLINE int
856 #   if 0
857 rpl_iswspace
858 #   else
859 iswspace
860 #   endif
861          (wint_t wc)
862 {
863   return (wc == ' ' || wc == '\t'
864           || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
865 }
866 
867 _GL_WCTYPE_INLINE int
868 #   if 0
869 rpl_iswupper
870 #   else
871 iswupper
872 #   endif
873          (wint_t wc)
874 {
875   return wc >= 'A' && wc <= 'Z';
876 }
877 
878 _GL_WCTYPE_INLINE int
879 #   if 0
880 rpl_iswxdigit
881 #   else
882 iswxdigit
883 #   endif
884           (wint_t wc)
885 {
886   return ((wc >= '0' && wc <= '9')
887           || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
888 }
889 
890 _GL_WCTYPE_INLINE wint_t
891 #   if 0
892 rpl_towlower
893 #   else
894 towlower
895 #   endif
896          (wint_t wc)
897 {
898   return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
899 }
900 
901 _GL_WCTYPE_INLINE wint_t
902 #   if 0
903 rpl_towupper
904 #   else
905 towupper
906 #   endif
907          (wint_t wc)
908 {
909   return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
910 }
911 
912 #  endif
913 
914 # elif 1 && (! 1 || 0)
915 /* Only the iswblank function is missing.  */
916 
917 #  if 0
918 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
919 #    define iswblank rpl_iswblank
920 #   endif
921 _GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
922 #  else
923 _GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
924 #  endif
925 
926 # endif
927 
928 # if defined __MINGW32__ && !0
929 
930 /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
931    The functions towlower and towupper are implemented in the MSVCRT library
932    to take a wchar_t argument and return a wchar_t result.  mingw declares
933    these functions to take a wint_t argument and return a wint_t result.
934    This means that:
935    1. When the user passes an argument outside the range 0x0000..0xFFFF, the
936       function will look only at the lower 16 bits.  This is allowed according
937       to POSIX.
938    2. The return value is returned in the lower 16 bits of the result register.
939       The upper 16 bits are random: whatever happened to be in that part of the
940       result register.  We need to fix this by adding a zero-extend from
941       wchar_t to wint_t after the call.  */
942 
943 _GL_WCTYPE_INLINE wint_t
944 rpl_towlower (wint_t wc)
945 {
946   return (wint_t) (wchar_t) towlower (wc);
947 }
948 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
949 #   define towlower rpl_towlower
950 #  endif
951 
952 _GL_WCTYPE_INLINE wint_t
953 rpl_towupper (wint_t wc)
954 {
955   return (wint_t) (wchar_t) towupper (wc);
956 }
957 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
958 #   define towupper rpl_towupper
959 #  endif
960 
961 # endif /* __MINGW32__ && !0 */
962 
963 # define GNULIB_defined_wctype_functions 1
964 #endif
965 
966 #if 0
967 _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
968 _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
969 _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
970 _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
971 _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
972 _GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
973 _GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
974 _GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
975 _GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
976 _GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
977 _GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
978 #else
979 _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
980 _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
981 _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
982 _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
983 _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
984 _GL_CXXALIAS_SYS (iswlower, int, (wint_t wc));
985 _GL_CXXALIAS_SYS (iswprint, int, (wint_t wc));
986 _GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc));
987 _GL_CXXALIAS_SYS (iswspace, int, (wint_t wc));
988 _GL_CXXALIAS_SYS (iswupper, int, (wint_t wc));
989 _GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
990 #endif
991 #if __GLIBC__ >= 2
992 _GL_CXXALIASWARN (iswalnum);
993 _GL_CXXALIASWARN (iswalpha);
994 _GL_CXXALIASWARN (iswcntrl);
995 _GL_CXXALIASWARN (iswdigit);
996 _GL_CXXALIASWARN (iswgraph);
997 _GL_CXXALIASWARN (iswlower);
998 _GL_CXXALIASWARN (iswprint);
999 _GL_CXXALIASWARN (iswpunct);
1000 _GL_CXXALIASWARN (iswspace);
1001 _GL_CXXALIASWARN (iswupper);
1002 _GL_CXXALIASWARN (iswxdigit);
1003 #endif
1004 
1005 #if 1
1006 # if 0 || 0
1007 _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
1008 # else
1009 _GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
1010 # endif
1011 # if __GLIBC__ >= 2
1012 _GL_CXXALIASWARN (iswblank);
1013 # endif
1014 #endif
1015 
1016 #if !1
1017 # if !GNULIB_defined_wctype_t
1018 typedef void * wctype_t;
1019 #  define GNULIB_defined_wctype_t 1
1020 # endif
1021 #endif
1022 
1023 /* Get a descriptor for a wide character property.  */
1024 #if 0
1025 # if !1
1026 _GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name));
1027 # endif
1028 _GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
1029 # if __GLIBC__ >= 2
1030 _GL_CXXALIASWARN (wctype);
1031 # endif
1032 #elif defined GNULIB_POSIXCHECK
1033 # undef wctype
1034 # if HAVE_RAW_DECL_WCTYPE
1035 _GL_WARN_ON_USE (wctype, "wctype is unportable - "
1036                  "use gnulib module wctype for portability");
1037 # endif
1038 #endif
1039 
1040 /* Test whether a wide character has a given property.
1041    The argument WC must be either a wchar_t value or WEOF.
1042    The argument DESC must have been returned by the wctype() function.  */
1043 #if 1
1044 # if 0
1045 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1046 #   undef iswctype
1047 #   define iswctype rpl_iswctype
1048 #  endif
1049 _GL_FUNCDECL_RPL (iswctype, int, (wint_t wc, wctype_t desc));
1050 _GL_CXXALIAS_RPL (iswctype, int, (wint_t wc, wctype_t desc));
1051 # else
1052 #  if !1
1053 _GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc));
1054 #  endif
1055 _GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
1056 # endif
1057 # if __GLIBC__ >= 2
1058 _GL_CXXALIASWARN (iswctype);
1059 # endif
1060 #elif defined GNULIB_POSIXCHECK
1061 # undef iswctype
1062 # if HAVE_RAW_DECL_ISWCTYPE
1063 _GL_WARN_ON_USE (iswctype, "iswctype is unportable - "
1064                  "use gnulib module iswctype for portability");
1065 # endif
1066 #endif
1067 
1068 #if 0 || defined __MINGW32__
1069 _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
1070 _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
1071 #else
1072 _GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc));
1073 _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
1074 #endif
1075 #if __GLIBC__ >= 2
1076 _GL_CXXALIASWARN (towlower);
1077 _GL_CXXALIASWARN (towupper);
1078 #endif
1079 
1080 #if !1
1081 # if !GNULIB_defined_wctrans_t
1082 typedef void * wctrans_t;
1083 #  define GNULIB_defined_wctrans_t 1
1084 # endif
1085 #endif
1086 
1087 /* Get a descriptor for a wide character case conversion.  */
1088 #if 0
1089 # if !1
1090 _GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name));
1091 # endif
1092 _GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
1093 # if __GLIBC__ >= 2
1094 _GL_CXXALIASWARN (wctrans);
1095 # endif
1096 #elif defined GNULIB_POSIXCHECK
1097 # undef wctrans
1098 # if HAVE_RAW_DECL_WCTRANS
1099 _GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
1100                  "use gnulib module wctrans for portability");
1101 # endif
1102 #endif
1103 
1104 /* Perform a given case conversion on a wide character.
1105    The argument WC must be either a wchar_t value or WEOF.
1106    The argument DESC must have been returned by the wctrans() function.  */
1107 #if 0
1108 # if !1
1109 _GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
1110 # endif
1111 _GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
1112 # if __GLIBC__ >= 2
1113 _GL_CXXALIASWARN (towctrans);
1114 # endif
1115 #elif defined GNULIB_POSIXCHECK
1116 # undef towctrans
1117 # if HAVE_RAW_DECL_TOWCTRANS
1118 _GL_WARN_ON_USE (towctrans, "towctrans is unportable - "
1119                  "use gnulib module towctrans for portability");
1120 # endif
1121 #endif
1122 
1123 _GL_INLINE_HEADER_END
1124 
1125 #endif /* _GL_WCTYPE_H */
1126 #endif /* _GL_WCTYPE_H */
1127 #endif
1128