1 | /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ |
2 | /* A substitute for ISO C99 <wctype.h>, for platforms that lack it. |
3 | |
4 | Copyright (C) 2006-2019 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 | * <http://www.opengroup.org/susv3xbd/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-2019 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-2019 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 | Assume all 11 functions (all isw* except iswblank) are implemented the |
585 | same way, or not at all. */ |
586 | # if ! 1 || 0 |
587 | |
588 | /* IRIX 5.3 has macros but no functions, its isw* macros refer to an |
589 | undefined variable _ctmp_ and to <ctype.h> macros like _P, and they |
590 | refer to system functions like _iswctype that are not in the |
591 | standard C library. Rather than try to get ancient buggy |
592 | implementations like this to work, just disable them. */ |
593 | # undef iswalnum |
594 | # undef iswalpha |
595 | # undef iswblank |
596 | # undef iswcntrl |
597 | # undef iswdigit |
598 | # undef iswgraph |
599 | # undef iswlower |
600 | # undef iswprint |
601 | # undef iswpunct |
602 | # undef iswspace |
603 | # undef iswupper |
604 | # undef iswxdigit |
605 | # undef towlower |
606 | # undef towupper |
607 | |
608 | /* Linux libc5 has <wctype.h> and the functions but they are broken. */ |
609 | # if 0 |
610 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
611 | # define iswalnum rpl_iswalnum |
612 | # define iswalpha rpl_iswalpha |
613 | # define iswblank rpl_iswblank |
614 | # define iswcntrl rpl_iswcntrl |
615 | # define iswdigit rpl_iswdigit |
616 | # define iswgraph rpl_iswgraph |
617 | # define iswlower rpl_iswlower |
618 | # define iswprint rpl_iswprint |
619 | # define iswpunct rpl_iswpunct |
620 | # define iswspace rpl_iswspace |
621 | # define iswupper rpl_iswupper |
622 | # define iswxdigit rpl_iswxdigit |
623 | # endif |
624 | # endif |
625 | # if 0 |
626 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
627 | # define towlower rpl_towlower |
628 | # define towupper rpl_towupper |
629 | # endif |
630 | # endif |
631 | |
632 | _GL_WCTYPE_INLINE int |
633 | # if 0 |
634 | rpl_iswalnum |
635 | # else |
636 | iswalnum |
637 | # endif |
638 | (wint_t wc) |
639 | { |
640 | return ((wc >= '0' && wc <= '9') |
641 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); |
642 | } |
643 | |
644 | _GL_WCTYPE_INLINE int |
645 | # if 0 |
646 | rpl_iswalpha |
647 | # else |
648 | iswalpha |
649 | # endif |
650 | (wint_t wc) |
651 | { |
652 | return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; |
653 | } |
654 | |
655 | _GL_WCTYPE_INLINE int |
656 | # if 0 |
657 | rpl_iswblank |
658 | # else |
659 | iswblank |
660 | # endif |
661 | (wint_t wc) |
662 | { |
663 | return wc == ' ' || wc == '\t'; |
664 | } |
665 | |
666 | _GL_WCTYPE_INLINE int |
667 | # if 0 |
668 | rpl_iswcntrl |
669 | # else |
670 | iswcntrl |
671 | # endif |
672 | (wint_t wc) |
673 | { |
674 | return (wc & ~0x1f) == 0 || wc == 0x7f; |
675 | } |
676 | |
677 | _GL_WCTYPE_INLINE int |
678 | # if 0 |
679 | rpl_iswdigit |
680 | # else |
681 | iswdigit |
682 | # endif |
683 | (wint_t wc) |
684 | { |
685 | return wc >= '0' && wc <= '9'; |
686 | } |
687 | |
688 | _GL_WCTYPE_INLINE int |
689 | # if 0 |
690 | rpl_iswgraph |
691 | # else |
692 | iswgraph |
693 | # endif |
694 | (wint_t wc) |
695 | { |
696 | return wc >= '!' && wc <= '~'; |
697 | } |
698 | |
699 | _GL_WCTYPE_INLINE int |
700 | # if 0 |
701 | rpl_iswlower |
702 | # else |
703 | iswlower |
704 | # endif |
705 | (wint_t wc) |
706 | { |
707 | return wc >= 'a' && wc <= 'z'; |
708 | } |
709 | |
710 | _GL_WCTYPE_INLINE int |
711 | # if 0 |
712 | rpl_iswprint |
713 | # else |
714 | iswprint |
715 | # endif |
716 | (wint_t wc) |
717 | { |
718 | return wc >= ' ' && wc <= '~'; |
719 | } |
720 | |
721 | _GL_WCTYPE_INLINE int |
722 | # if 0 |
723 | rpl_iswpunct |
724 | # else |
725 | iswpunct |
726 | # endif |
727 | (wint_t wc) |
728 | { |
729 | return (wc >= '!' && wc <= '~' |
730 | && !((wc >= '0' && wc <= '9') |
731 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))); |
732 | } |
733 | |
734 | _GL_WCTYPE_INLINE int |
735 | # if 0 |
736 | rpl_iswspace |
737 | # else |
738 | iswspace |
739 | # endif |
740 | (wint_t wc) |
741 | { |
742 | return (wc == ' ' || wc == '\t' |
743 | || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); |
744 | } |
745 | |
746 | _GL_WCTYPE_INLINE int |
747 | # if 0 |
748 | rpl_iswupper |
749 | # else |
750 | iswupper |
751 | # endif |
752 | (wint_t wc) |
753 | { |
754 | return wc >= 'A' && wc <= 'Z'; |
755 | } |
756 | |
757 | _GL_WCTYPE_INLINE int |
758 | # if 0 |
759 | rpl_iswxdigit |
760 | # else |
761 | iswxdigit |
762 | # endif |
763 | (wint_t wc) |
764 | { |
765 | return ((wc >= '0' && wc <= '9') |
766 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); |
767 | } |
768 | |
769 | _GL_WCTYPE_INLINE wint_t |
770 | # if 0 |
771 | rpl_towlower |
772 | # else |
773 | towlower |
774 | # endif |
775 | (wint_t wc) |
776 | { |
777 | return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc); |
778 | } |
779 | |
780 | _GL_WCTYPE_INLINE wint_t |
781 | # if 0 |
782 | rpl_towupper |
783 | # else |
784 | towupper |
785 | # endif |
786 | (wint_t wc) |
787 | { |
788 | return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); |
789 | } |
790 | |
791 | # elif 0 && (! 1 || 0) |
792 | /* Only the iswblank function is missing. */ |
793 | |
794 | # if 0 |
795 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
796 | # define iswblank rpl_iswblank |
797 | # endif |
798 | _GL_FUNCDECL_RPL (iswblank, int, (wint_t wc)); |
799 | # else |
800 | _GL_FUNCDECL_SYS (iswblank, int, (wint_t wc)); |
801 | # endif |
802 | |
803 | # endif |
804 | |
805 | # if defined __MINGW32__ |
806 | |
807 | /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t. |
808 | The functions towlower and towupper are implemented in the MSVCRT library |
809 | to take a wchar_t argument and return a wchar_t result. mingw declares |
810 | these functions to take a wint_t argument and return a wint_t result. |
811 | This means that: |
812 | 1. When the user passes an argument outside the range 0x0000..0xFFFF, the |
813 | function will look only at the lower 16 bits. This is allowed according |
814 | to POSIX. |
815 | 2. The return value is returned in the lower 16 bits of the result register. |
816 | The upper 16 bits are random: whatever happened to be in that part of the |
817 | result register. We need to fix this by adding a zero-extend from |
818 | wchar_t to wint_t after the call. */ |
819 | |
820 | _GL_WCTYPE_INLINE wint_t |
821 | rpl_towlower (wint_t wc) |
822 | { |
823 | return (wint_t) (wchar_t) towlower (wc); |
824 | } |
825 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
826 | # define towlower rpl_towlower |
827 | # endif |
828 | |
829 | _GL_WCTYPE_INLINE wint_t |
830 | rpl_towupper (wint_t wc) |
831 | { |
832 | return (wint_t) (wchar_t) towupper (wc); |
833 | } |
834 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
835 | # define towupper rpl_towupper |
836 | # endif |
837 | |
838 | # endif /* __MINGW32__ */ |
839 | |
840 | # define GNULIB_defined_wctype_functions 1 |
841 | #endif |
842 | |
843 | #if 0 |
844 | _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc)); |
845 | _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc)); |
846 | _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc)); |
847 | _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc)); |
848 | _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc)); |
849 | _GL_CXXALIAS_RPL (iswlower, int, (wint_t wc)); |
850 | _GL_CXXALIAS_RPL (iswprint, int, (wint_t wc)); |
851 | _GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc)); |
852 | _GL_CXXALIAS_RPL (iswspace, int, (wint_t wc)); |
853 | _GL_CXXALIAS_RPL (iswupper, int, (wint_t wc)); |
854 | _GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc)); |
855 | #else |
856 | _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc)); |
857 | _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc)); |
858 | _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc)); |
859 | _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc)); |
860 | _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc)); |
861 | _GL_CXXALIAS_SYS (iswlower, int, (wint_t wc)); |
862 | _GL_CXXALIAS_SYS (iswprint, int, (wint_t wc)); |
863 | _GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc)); |
864 | _GL_CXXALIAS_SYS (iswspace, int, (wint_t wc)); |
865 | _GL_CXXALIAS_SYS (iswupper, int, (wint_t wc)); |
866 | _GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc)); |
867 | #endif |
868 | _GL_CXXALIASWARN (iswalnum); |
869 | _GL_CXXALIASWARN (iswalpha); |
870 | _GL_CXXALIASWARN (iswcntrl); |
871 | _GL_CXXALIASWARN (iswdigit); |
872 | _GL_CXXALIASWARN (iswgraph); |
873 | _GL_CXXALIASWARN (iswlower); |
874 | _GL_CXXALIASWARN (iswprint); |
875 | _GL_CXXALIASWARN (iswpunct); |
876 | _GL_CXXALIASWARN (iswspace); |
877 | _GL_CXXALIASWARN (iswupper); |
878 | _GL_CXXALIASWARN (iswxdigit); |
879 | |
880 | #if 0 |
881 | # if 0 || 0 |
882 | _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc)); |
883 | # else |
884 | _GL_CXXALIAS_SYS (iswblank, int, (wint_t wc)); |
885 | # endif |
886 | _GL_CXXALIASWARN (iswblank); |
887 | #endif |
888 | |
889 | #if !1 |
890 | # if !GNULIB_defined_wctype_t |
891 | typedef void * wctype_t; |
892 | # define GNULIB_defined_wctype_t 1 |
893 | # endif |
894 | #endif |
895 | |
896 | /* Get a descriptor for a wide character property. */ |
897 | #if 0 |
898 | # if !1 |
899 | _GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name)); |
900 | # endif |
901 | _GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name)); |
902 | _GL_CXXALIASWARN (wctype); |
903 | #elif defined GNULIB_POSIXCHECK |
904 | # undef wctype |
905 | # if HAVE_RAW_DECL_WCTYPE |
906 | _GL_WARN_ON_USE (wctype, "wctype is unportable - " |
907 | "use gnulib module wctype for portability" ); |
908 | # endif |
909 | #endif |
910 | |
911 | /* Test whether a wide character has a given property. |
912 | The argument WC must be either a wchar_t value or WEOF. |
913 | The argument DESC must have been returned by the wctype() function. */ |
914 | #if 0 |
915 | # if !1 |
916 | _GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc)); |
917 | # endif |
918 | _GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc)); |
919 | _GL_CXXALIASWARN (iswctype); |
920 | #elif defined GNULIB_POSIXCHECK |
921 | # undef iswctype |
922 | # if HAVE_RAW_DECL_ISWCTYPE |
923 | _GL_WARN_ON_USE (iswctype, "iswctype is unportable - " |
924 | "use gnulib module iswctype for portability" ); |
925 | # endif |
926 | #endif |
927 | |
928 | #if 0 || defined __MINGW32__ |
929 | _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc)); |
930 | _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc)); |
931 | #else |
932 | _GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc)); |
933 | _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc)); |
934 | #endif |
935 | _GL_CXXALIASWARN (towlower); |
936 | _GL_CXXALIASWARN (towupper); |
937 | |
938 | #if !1 |
939 | # if !GNULIB_defined_wctrans_t |
940 | typedef void * wctrans_t; |
941 | # define GNULIB_defined_wctrans_t 1 |
942 | # endif |
943 | #endif |
944 | |
945 | /* Get a descriptor for a wide character case conversion. */ |
946 | #if 0 |
947 | # if !1 |
948 | _GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name)); |
949 | # endif |
950 | _GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name)); |
951 | _GL_CXXALIASWARN (wctrans); |
952 | #elif defined GNULIB_POSIXCHECK |
953 | # undef wctrans |
954 | # if HAVE_RAW_DECL_WCTRANS |
955 | _GL_WARN_ON_USE (wctrans, "wctrans is unportable - " |
956 | "use gnulib module wctrans for portability" ); |
957 | # endif |
958 | #endif |
959 | |
960 | /* Perform a given case conversion on a wide character. |
961 | The argument WC must be either a wchar_t value or WEOF. |
962 | The argument DESC must have been returned by the wctrans() function. */ |
963 | #if 0 |
964 | # if !1 |
965 | _GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); |
966 | # endif |
967 | _GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); |
968 | _GL_CXXALIASWARN (towctrans); |
969 | #elif defined GNULIB_POSIXCHECK |
970 | # undef towctrans |
971 | # if HAVE_RAW_DECL_TOWCTRANS |
972 | _GL_WARN_ON_USE (towctrans, "towctrans is unportable - " |
973 | "use gnulib module towctrans for portability" ); |
974 | # endif |
975 | #endif |
976 | |
977 | _GL_INLINE_HEADER_END |
978 | |
979 | #endif /* _GL_WCTYPE_H */ |
980 | #endif /* _GL_WCTYPE_H */ |
981 | #endif |
982 | |