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