Line data Source code
1 : /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 : /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
3 :
4 : Copyright (C) 2007-2025 Free Software Foundation, Inc.
5 :
6 : This file is free software: you can redistribute it and/or modify
7 : it under the terms of the GNU Lesser General Public License as
8 : published by the Free Software Foundation; either version 2.1 of the
9 : License, or (at your option) any later version.
10 :
11 : This file 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 Lesser General Public License for more details.
15 :
16 : You should have received a copy of the GNU Lesser General Public License
17 : along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 :
19 : /* Written by Eric Blake. */
20 :
21 : /*
22 : * ISO C 99 <wchar.h> for platforms that have issues.
23 : * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wchar.h.html>
24 : *
25 : * For now, this just ensures proper prerequisite inclusion order and
26 : * the declaration of wcwidth().
27 : */
28 :
29 : #if __GNUC__ >= 3
30 : #pragma GCC system_header
31 : #endif
32 :
33 :
34 : #if (((defined __need_mbstate_t || defined __need_wint_t) \
35 : && !defined __MINGW32__) \
36 : || (defined __hpux \
37 : && ((defined _INTTYPES_INCLUDED \
38 : && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \
39 : || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
40 : || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
41 : || defined _GL_ALREADY_INCLUDING_WCHAR_H)
42 : /* Special invocation convention:
43 : - Inside glibc and uClibc header files, but not MinGW.
44 : - On HP-UX 11.00 we have a sequence of nested includes
45 : <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
46 : once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
47 : and once directly. In both situations 'wint_t' is not yet defined,
48 : therefore we cannot provide the function overrides; instead include only
49 : the system's <wchar.h>.
50 : - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of
51 : <wchar.h> is actually processed, and that doesn't include 'mbstate_t'.
52 : - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
53 : the latter includes <wchar.h>. But here, we have no way to detect whether
54 : <wctype.h> is completely included or is still being included. */
55 :
56 : #include_next <wchar.h>
57 : /* The glibc 2.5 /usr/include/wchar.h defines __need_wint_t but never undefines
58 : it. We need to do that here. */
59 : #undef __need_wint_t
60 :
61 : #else
62 : /* Normal invocation convention. */
63 :
64 : #ifndef _GL_WCHAR_H
65 :
66 : #define _GL_ALREADY_INCLUDING_WCHAR_H
67 :
68 : #if 1
69 : # include <features.h> /* for __GLIBC__ */
70 : #endif
71 :
72 : /* In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
73 : by <stddef.h>.
74 : But avoid namespace pollution on glibc systems. */
75 : #if !(defined __GLIBC__ && !defined __UCLIBC__)
76 : # include <stddef.h>
77 : #endif
78 :
79 : /* Include the original <wchar.h> if it exists.
80 : Some builds of uClibc lack it. */
81 : /* The include_next requires a split double-inclusion guard. */
82 : #if 1
83 : # include_next <wchar.h>
84 : #endif
85 :
86 : #undef _GL_ALREADY_INCLUDING_WCHAR_H
87 :
88 : #ifndef _GL_WCHAR_H
89 : #define _GL_WCHAR_H
90 :
91 : /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
92 : _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
93 : HAVE_RAW_DECL_*. */
94 : #if !_GL_CONFIG_H_INCLUDED
95 : #error "Please include config.h first."
96 : #endif
97 :
98 : /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
99 : that can be freed by passing them as the Ith argument to the
100 : function F. */
101 : #ifndef _GL_ATTRIBUTE_DEALLOC
102 : # if __GNUC__ >= 11 && !defined __clang__
103 : # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
104 : # else
105 : # define _GL_ATTRIBUTE_DEALLOC(f, i)
106 : # endif
107 : #endif
108 :
109 : /* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
110 : can be freed via 'free'; it can be used only after declaring 'free'. */
111 : /* Applies to: functions. Cannot be used on inline functions. */
112 : #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
113 : # if defined __cplusplus && defined __GNUC__ && !defined __clang__
114 : /* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
115 : # define _GL_ATTRIBUTE_DEALLOC_FREE \
116 : _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
117 : # else
118 : # define _GL_ATTRIBUTE_DEALLOC_FREE \
119 : _GL_ATTRIBUTE_DEALLOC (free, 1)
120 : # endif
121 : #endif
122 :
123 : /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
124 : allocated memory. */
125 : /* Applies to: functions. */
126 : #ifndef _GL_ATTRIBUTE_MALLOC
127 : # if __GNUC__ >= 3 || defined __clang__
128 : # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
129 : # else
130 : # define _GL_ATTRIBUTE_MALLOC
131 : # endif
132 : #endif
133 :
134 : /* The __attribute__ feature is available in gcc versions 2.5 and later.
135 : The attribute __pure__ was added in gcc 2.96. */
136 : #ifndef _GL_ATTRIBUTE_PURE
137 : # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
138 : # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
139 : # else
140 : # define _GL_ATTRIBUTE_PURE /* empty */
141 : # endif
142 : #endif
143 :
144 : /* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP
145 : (a pointer) must not be NULL if the argument NI (an integer) is != 0. */
146 : /* Applies to: functions. */
147 : #ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO
148 : # if __GNUC__ >= 15 && !defined __clang__
149 : # define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) \
150 : __attribute__ ((__nonnull_if_nonzero__ (np, ni)))
151 : # else
152 : # define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni)
153 : # endif
154 : #endif
155 :
156 : /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
157 : */
158 : #ifndef _GL_ATTRIBUTE_NOTHROW
159 : # if defined __cplusplus
160 : # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
161 : # if __cplusplus >= 201103L
162 : # define _GL_ATTRIBUTE_NOTHROW noexcept (true)
163 : # else
164 : # define _GL_ATTRIBUTE_NOTHROW throw ()
165 : # endif
166 : # else
167 : # define _GL_ATTRIBUTE_NOTHROW
168 : # endif
169 : # else
170 : # if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
171 : # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
172 : # else
173 : # define _GL_ATTRIBUTE_NOTHROW
174 : # endif
175 : # endif
176 : #endif
177 :
178 : /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
179 : /* C++ compatible function declaration macros.
180 : Copyright (C) 2010-2025 Free Software Foundation, Inc.
181 :
182 : This program is free software: you can redistribute it and/or modify it
183 : under the terms of the GNU Lesser General Public License as published
184 : by the Free Software Foundation; either version 2 of the License, or
185 : (at your option) any later version.
186 :
187 : This program is distributed in the hope that it will be useful,
188 : but WITHOUT ANY WARRANTY; without even the implied warranty of
189 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
190 : Lesser General Public License for more details.
191 :
192 : You should have received a copy of the GNU Lesser General Public License
193 : along with this program. If not, see <https://www.gnu.org/licenses/>. */
194 :
195 : #ifndef _GL_CXXDEFS_H
196 : #define _GL_CXXDEFS_H
197 :
198 : /* Begin/end the GNULIB_NAMESPACE namespace. */
199 : #if defined __cplusplus && defined GNULIB_NAMESPACE
200 : # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
201 : # define _GL_END_NAMESPACE }
202 : #else
203 : # define _GL_BEGIN_NAMESPACE
204 : # define _GL_END_NAMESPACE
205 : #endif
206 :
207 : /* The three most frequent use cases of these macros are:
208 :
209 : * For providing a substitute for a function that is missing on some
210 : platforms, but is declared and works fine on the platforms on which
211 : it exists:
212 :
213 : #if @GNULIB_FOO@
214 : # if !@HAVE_FOO@
215 : _GL_FUNCDECL_SYS (foo, ...);
216 : # endif
217 : _GL_CXXALIAS_SYS (foo, ...);
218 : _GL_CXXALIASWARN (foo);
219 : #elif defined GNULIB_POSIXCHECK
220 : ...
221 : #endif
222 :
223 : * For providing a replacement for a function that exists on all platforms,
224 : but is broken/insufficient and needs to be replaced on some platforms:
225 :
226 : #if @GNULIB_FOO@
227 : # if @REPLACE_FOO@
228 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
229 : # undef foo
230 : # define foo rpl_foo
231 : # endif
232 : _GL_FUNCDECL_RPL (foo, ...);
233 : _GL_CXXALIAS_RPL (foo, ...);
234 : # else
235 : _GL_CXXALIAS_SYS (foo, ...);
236 : # endif
237 : _GL_CXXALIASWARN (foo);
238 : #elif defined GNULIB_POSIXCHECK
239 : ...
240 : #endif
241 :
242 : * For providing a replacement for a function that exists on some platforms
243 : but is broken/insufficient and needs to be replaced on some of them and
244 : is additionally either missing or undeclared on some other platforms:
245 :
246 : #if @GNULIB_FOO@
247 : # if @REPLACE_FOO@
248 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
249 : # undef foo
250 : # define foo rpl_foo
251 : # endif
252 : _GL_FUNCDECL_RPL (foo, ...);
253 : _GL_CXXALIAS_RPL (foo, ...);
254 : # else
255 : # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
256 : _GL_FUNCDECL_SYS (foo, ...);
257 : # endif
258 : _GL_CXXALIAS_SYS (foo, ...);
259 : # endif
260 : _GL_CXXALIASWARN (foo);
261 : #elif defined GNULIB_POSIXCHECK
262 : ...
263 : #endif
264 : */
265 :
266 : /* _GL_EXTERN_C declaration;
267 : performs the declaration with C linkage. */
268 : #if defined __cplusplus
269 : # define _GL_EXTERN_C extern "C"
270 : #else
271 : # define _GL_EXTERN_C extern
272 : #endif
273 :
274 : /* _GL_EXTERN_C_FUNC declaration;
275 : performs the declaration of a function with C linkage. */
276 : #if defined __cplusplus
277 : # define _GL_EXTERN_C_FUNC extern "C"
278 : #else
279 : /* In C mode, omit the 'extern' keyword, because attributes in bracket syntax
280 : are not allowed between 'extern' and the return type (see gnulib-common.m4).
281 : */
282 : # define _GL_EXTERN_C_FUNC
283 : #endif
284 :
285 : /* _GL_FUNCDECL_RPL (func, rettype, parameters, [attributes]);
286 : declares a replacement function, named rpl_func, with the given prototype,
287 : consisting of return type, parameters, and attributes.
288 : Although attributes are optional, the comma before them is required
289 : for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
290 : if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
291 : at the end of the declaration.
292 : Examples:
293 : _GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
294 : _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
295 : _GL_ARG_NONNULL ((1)));
296 :
297 : Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front
298 : of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's
299 : because
300 : [[...]] extern "C" <declaration>;
301 : is invalid syntax in C++.)
302 : */
303 : #define _GL_FUNCDECL_RPL(func,rettype,parameters,...) \
304 : _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters, __VA_ARGS__)
305 : #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \
306 : _GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters
307 :
308 : /* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]);
309 : declares the system function, named func, with the given prototype,
310 : consisting of return type, parameters, and attributes.
311 : Although attributes are optional, the comma before them is required
312 : for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
313 : if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
314 : at the end of the declaration.
315 : Examples:
316 : _GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
317 : _GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
318 : */
319 : #define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \
320 : _GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters
321 :
322 : /* _GL_CXXALIAS_RPL (func, rettype, parameters);
323 : declares a C++ alias called GNULIB_NAMESPACE::func
324 : that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
325 : Example:
326 : _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
327 :
328 : Wrapping rpl_func in an object with an inline conversion operator
329 : avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
330 : actually used in the program. */
331 : #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
332 : _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
333 : #if defined __cplusplus && defined GNULIB_NAMESPACE
334 : # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
335 : namespace GNULIB_NAMESPACE \
336 : { \
337 : static const struct _gl_ ## func ## _wrapper \
338 : { \
339 : typedef rettype (*type) parameters; \
340 : \
341 : inline operator type () const \
342 : { \
343 : return ::rpl_func; \
344 : } \
345 : } func = {}; \
346 : } \
347 : _GL_EXTERN_C int _gl_cxxalias_dummy
348 : #else
349 : # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
350 : _GL_EXTERN_C int _gl_cxxalias_dummy
351 : #endif
352 :
353 : /* _GL_CXXALIAS_MDA (func, rettype, parameters);
354 : is to be used when func is a Microsoft deprecated alias, on native Windows.
355 : It declares a C++ alias called GNULIB_NAMESPACE::func
356 : that redirects to _func, if GNULIB_NAMESPACE is defined.
357 : Example:
358 : _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
359 : */
360 : #define _GL_CXXALIAS_MDA(func,rettype,parameters) \
361 : _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
362 :
363 : /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
364 : is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
365 : except that the C function rpl_func may have a slightly different
366 : declaration. A cast is used to silence the "invalid conversion" error
367 : that would otherwise occur. */
368 : #if defined __cplusplus && defined GNULIB_NAMESPACE
369 : # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
370 : namespace GNULIB_NAMESPACE \
371 : { \
372 : static const struct _gl_ ## func ## _wrapper \
373 : { \
374 : typedef rettype (*type) parameters; \
375 : \
376 : inline operator type () const \
377 : { \
378 : return reinterpret_cast<type>(::rpl_func); \
379 : } \
380 : } func = {}; \
381 : } \
382 : _GL_EXTERN_C int _gl_cxxalias_dummy
383 : #else
384 : # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
385 : _GL_EXTERN_C int _gl_cxxalias_dummy
386 : #endif
387 :
388 : /* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
389 : is like _GL_CXXALIAS_MDA (func, rettype, parameters);
390 : except that the C function func may have a slightly different declaration.
391 : A cast is used to silence the "invalid conversion" error that would
392 : otherwise occur. */
393 : #define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
394 : _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
395 :
396 : /* _GL_CXXALIAS_SYS (func, rettype, parameters);
397 : declares a C++ alias called GNULIB_NAMESPACE::func
398 : that redirects to the system provided function func, if GNULIB_NAMESPACE
399 : is defined.
400 : Example:
401 : _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
402 :
403 : Wrapping func in an object with an inline conversion operator
404 : avoids a reference to func unless GNULIB_NAMESPACE::func is
405 : actually used in the program. */
406 : #if defined __cplusplus && defined GNULIB_NAMESPACE
407 : # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
408 : namespace GNULIB_NAMESPACE \
409 : { \
410 : static const struct _gl_ ## func ## _wrapper \
411 : { \
412 : typedef rettype (*type) parameters; \
413 : \
414 : inline operator type () const \
415 : { \
416 : return ::func; \
417 : } \
418 : } func = {}; \
419 : } \
420 : _GL_EXTERN_C int _gl_cxxalias_dummy
421 : #else
422 : # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
423 : _GL_EXTERN_C int _gl_cxxalias_dummy
424 : #endif
425 :
426 : /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
427 : is like _GL_CXXALIAS_SYS (func, rettype, parameters);
428 : except that the C function func may have a slightly different declaration.
429 : A cast is used to silence the "invalid conversion" error that would
430 : otherwise occur. */
431 : #if defined __cplusplus && defined GNULIB_NAMESPACE
432 : # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
433 : namespace GNULIB_NAMESPACE \
434 : { \
435 : static const struct _gl_ ## func ## _wrapper \
436 : { \
437 : typedef rettype (*type) parameters; \
438 : \
439 : inline operator type () const \
440 : { \
441 : return reinterpret_cast<type>(::func); \
442 : } \
443 : } func = {}; \
444 : } \
445 : _GL_EXTERN_C int _gl_cxxalias_dummy
446 : #else
447 : # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
448 : _GL_EXTERN_C int _gl_cxxalias_dummy
449 : #endif
450 :
451 : /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
452 : is like _GL_CXXALIAS_SYS (func, rettype, parameters);
453 : except that the C function is picked among a set of overloaded functions,
454 : namely the one with rettype2 and parameters2. Two consecutive casts
455 : are used to silence the "cannot find a match" and "invalid conversion"
456 : errors that would otherwise occur. */
457 : #if defined __cplusplus && defined GNULIB_NAMESPACE
458 : /* The outer cast must be a reinterpret_cast.
459 : The inner cast: When the function is defined as a set of overloaded
460 : functions, it works as a static_cast<>, choosing the designated variant.
461 : When the function is defined as a single variant, it works as a
462 : reinterpret_cast<>. The parenthesized cast syntax works both ways. */
463 : # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
464 : namespace GNULIB_NAMESPACE \
465 : { \
466 : static const struct _gl_ ## func ## _wrapper \
467 : { \
468 : typedef rettype (*type) parameters; \
469 : \
470 : inline operator type () const \
471 : { \
472 : return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
473 : } \
474 : } func = {}; \
475 : } \
476 : _GL_EXTERN_C int _gl_cxxalias_dummy
477 : #else
478 : # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
479 : _GL_EXTERN_C int _gl_cxxalias_dummy
480 : #endif
481 :
482 : /* _GL_CXXALIASWARN (func);
483 : causes a warning to be emitted when ::func is used but not when
484 : GNULIB_NAMESPACE::func is used. func must be defined without overloaded
485 : variants. */
486 : #if defined __cplusplus && defined GNULIB_NAMESPACE
487 : # define _GL_CXXALIASWARN(func) \
488 : _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
489 : # define _GL_CXXALIASWARN_1(func,namespace) \
490 : _GL_CXXALIASWARN_2 (func, namespace)
491 : /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
492 : we enable the warning only when not optimizing. */
493 : # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
494 : # define _GL_CXXALIASWARN_2(func,namespace) \
495 : _GL_WARN_ON_USE (func, \
496 : "The symbol ::" #func " refers to the system function. " \
497 : "Use " #namespace "::" #func " instead.")
498 : # elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
499 : # define _GL_CXXALIASWARN_2(func,namespace) \
500 : extern __typeof__ (func) func
501 : # else
502 : # define _GL_CXXALIASWARN_2(func,namespace) \
503 : _GL_EXTERN_C int _gl_cxxalias_dummy
504 : # endif
505 : #else
506 : # define _GL_CXXALIASWARN(func) \
507 : _GL_EXTERN_C int _gl_cxxalias_dummy
508 : #endif
509 :
510 : /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
511 : causes a warning to be emitted when the given overloaded variant of ::func
512 : is used but not when GNULIB_NAMESPACE::func is used. */
513 : #if defined __cplusplus && defined GNULIB_NAMESPACE
514 : # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
515 : _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
516 : GNULIB_NAMESPACE)
517 : # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
518 : _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
519 : /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
520 : we enable the warning only when not optimizing. */
521 : # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
522 : # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
523 : _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
524 : "The symbol ::" #func " refers to the system function. " \
525 : "Use " #namespace "::" #func " instead.")
526 : # else
527 : # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
528 : _GL_EXTERN_C int _gl_cxxalias_dummy
529 : # endif
530 : #else
531 : # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
532 : _GL_EXTERN_C int _gl_cxxalias_dummy
533 : #endif
534 :
535 : #endif /* _GL_CXXDEFS_H */
536 :
537 : /* The definition of _GL_ARG_NONNULL is copied here. */
538 : /* A C macro for declaring that specific arguments must not be NULL.
539 : Copyright (C) 2009-2025 Free Software Foundation, Inc.
540 :
541 : This program is free software: you can redistribute it and/or modify it
542 : under the terms of the GNU Lesser General Public License as published
543 : by the Free Software Foundation; either version 2 of the License, or
544 : (at your option) any later version.
545 :
546 : This program is distributed in the hope that it will be useful,
547 : but WITHOUT ANY WARRANTY; without even the implied warranty of
548 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
549 : Lesser General Public License for more details.
550 :
551 : You should have received a copy of the GNU Lesser General Public License
552 : along with this program. If not, see <https://www.gnu.org/licenses/>. */
553 :
554 : /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
555 : that the values passed as arguments n, ..., m must be non-NULL pointers.
556 : n = 1 stands for the first argument, n = 2 for the second argument etc. */
557 : #ifndef _GL_ARG_NONNULL
558 : # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
559 : # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
560 : # else
561 : # define _GL_ARG_NONNULL(params)
562 : # endif
563 : #endif
564 :
565 : /* The definition of _GL_WARN_ON_USE is copied here. */
566 : /* A C macro for emitting warnings if a function is used.
567 : Copyright (C) 2010-2025 Free Software Foundation, Inc.
568 :
569 : This program is free software: you can redistribute it and/or modify it
570 : under the terms of the GNU Lesser General Public License as published
571 : by the Free Software Foundation; either version 2 of the License, or
572 : (at your option) any later version.
573 :
574 : This program is distributed in the hope that it will be useful,
575 : but WITHOUT ANY WARRANTY; without even the implied warranty of
576 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
577 : Lesser General Public License for more details.
578 :
579 : You should have received a copy of the GNU Lesser General Public License
580 : along with this program. If not, see <https://www.gnu.org/licenses/>. */
581 :
582 : /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
583 : for FUNCTION which will then trigger a compiler warning containing
584 : the text of "literal string" anywhere that function is called, if
585 : supported by the compiler. If the compiler does not support this
586 : feature, the macro expands to an unused extern declaration.
587 :
588 : _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
589 : attribute used in _GL_WARN_ON_USE. If the compiler does not support
590 : this feature, it expands to empty.
591 :
592 : These macros are useful for marking a function as a potential
593 : portability trap, with the intent that "literal string" include
594 : instructions on the replacement function that should be used
595 : instead.
596 : _GL_WARN_ON_USE is for functions with 'extern' linkage.
597 : _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
598 : linkage.
599 :
600 : _GL_WARN_ON_USE should not be used more than once for a given function
601 : in a given compilation unit (because this may generate a warning even
602 : if the function is never called).
603 :
604 : However, one of the reasons that a function is a portability trap is
605 : if it has the wrong signature. Declaring FUNCTION with a different
606 : signature in C is a compilation error, so this macro must use the
607 : same type as any existing declaration so that programs that avoid
608 : the problematic FUNCTION do not fail to compile merely because they
609 : included a header that poisoned the function. But this implies that
610 : _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
611 : have a declaration. Use of this macro implies that there must not
612 : be any other macro hiding the declaration of FUNCTION; but
613 : undefining FUNCTION first is part of the poisoning process anyway
614 : (although for symbols that are provided only via a macro, the result
615 : is a compilation error rather than a warning containing
616 : "literal string"). Also note that in C++, it is only safe to use if
617 : FUNCTION has no overloads.
618 :
619 : For an example, it is possible to poison 'getline' by:
620 : - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
621 : [getline]) in configure.ac, which potentially defines
622 : HAVE_RAW_DECL_GETLINE
623 : - adding this code to a header that wraps the system <stdio.h>:
624 : #undef getline
625 : #if HAVE_RAW_DECL_GETLINE
626 : _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
627 : "not universally present; use the gnulib module getline");
628 : #endif
629 :
630 : It is not possible to directly poison global variables. But it is
631 : possible to write a wrapper accessor function, and poison that
632 : (less common usage, like &environ, will cause a compilation error
633 : rather than issue the nice warning, but the end result of informing
634 : the developer about their portability problem is still achieved):
635 : #if HAVE_RAW_DECL_ENVIRON
636 : static char ***
637 : rpl_environ (void) { return &environ; }
638 : _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
639 : # undef environ
640 : # define environ (*rpl_environ ())
641 : #endif
642 : or better (avoiding contradictory use of 'static' and 'extern'):
643 : #if HAVE_RAW_DECL_ENVIRON
644 : static char ***
645 : _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
646 : rpl_environ (void) { return &environ; }
647 : # undef environ
648 : # define environ (*rpl_environ ())
649 : #endif
650 : */
651 : #ifndef _GL_WARN_ON_USE
652 :
653 : # if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
654 : /* A compiler attribute is available in gcc versions 4.3.0 and later. */
655 : # define _GL_WARN_ON_USE(function, message) \
656 : _GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
657 : # define _GL_WARN_ON_USE_ATTRIBUTE(message) \
658 : __attribute__ ((__warning__ (message)))
659 : # elif __clang_major__ >= 4
660 : /* Another compiler attribute is available in clang. */
661 : # define _GL_WARN_ON_USE(function, message) \
662 : _GL_WARN_EXTERN_C __typeof__ (function) function \
663 : __attribute__ ((__diagnose_if__ (1, message, "warning")))
664 : # define _GL_WARN_ON_USE_ATTRIBUTE(message) \
665 : __attribute__ ((__diagnose_if__ (1, message, "warning")))
666 : # elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
667 : /* Verify the existence of the function. */
668 : # define _GL_WARN_ON_USE(function, message) \
669 : _GL_WARN_EXTERN_C __typeof__ (function) function
670 : # define _GL_WARN_ON_USE_ATTRIBUTE(message)
671 : # else /* Unsupported. */
672 : # define _GL_WARN_ON_USE(function, message) \
673 : _GL_WARN_EXTERN_C int _gl_warn_on_use
674 : # define _GL_WARN_ON_USE_ATTRIBUTE(message)
675 : # endif
676 : #endif
677 :
678 : /* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
679 : is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
680 : function is declared with the given prototype, consisting of return type,
681 : parameters, and attributes.
682 : This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
683 : not work in this case. */
684 : #ifndef _GL_WARN_ON_USE_CXX
685 : # if !defined __cplusplus
686 : # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
687 : _GL_WARN_ON_USE (function, msg)
688 : # else
689 : # if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
690 : /* A compiler attribute is available in gcc versions 4.3.0 and later. */
691 : # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
692 : extern rettype_gcc function parameters_and_attributes \
693 : __attribute__ ((__warning__ (msg)))
694 : # elif __clang_major__ >= 4
695 : /* Another compiler attribute is available in clang. */
696 : # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
697 : extern rettype_clang function parameters_and_attributes \
698 : __attribute__ ((__diagnose_if__ (1, msg, "warning")))
699 : # elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
700 : /* Verify the existence of the function. */
701 : # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
702 : extern rettype_gcc function parameters_and_attributes
703 : # else /* Unsupported. */
704 : # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
705 : _GL_WARN_EXTERN_C int _gl_warn_on_use
706 : # endif
707 : # endif
708 : #endif
709 :
710 : /* _GL_WARN_EXTERN_C declaration;
711 : performs the declaration with C linkage. */
712 : #ifndef _GL_WARN_EXTERN_C
713 : # if defined __cplusplus
714 : # define _GL_WARN_EXTERN_C extern "C"
715 : # else
716 : # define _GL_WARN_EXTERN_C extern
717 : # endif
718 : #endif
719 :
720 :
721 : /* Define wint_t and WEOF. (Also done in wctype.in.h.) */
722 : #if !1 && !defined wint_t
723 : # define wint_t int
724 : # ifndef WEOF
725 : # define WEOF -1
726 : # endif
727 : #else
728 : /* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
729 : <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
730 : wint_t must be "unchanged by default argument promotions". Override it. */
731 : # if 0
732 : # if !GNULIB_defined_wint_t
733 : # if 0
734 : # include <crtdefs.h>
735 : # else
736 : # include <stddef.h>
737 : # endif
738 : typedef unsigned int rpl_wint_t;
739 : # undef wint_t
740 : # define wint_t rpl_wint_t
741 : # define GNULIB_defined_wint_t 1
742 : # endif
743 : # endif
744 : # ifndef WEOF
745 : # define WEOF ((wint_t) -1)
746 : # endif
747 : #endif
748 :
749 :
750 : /* Override mbstate_t if it is too small.
751 : On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
752 : implementing mbrtowc for encodings like UTF-8.
753 : On AIX, MSVC, and OpenBSD 6.0, mbrtowc needs to be overridden, but
754 : mbstate_t exists and is large enough and overriding it would cause problems
755 : in C++ mode. */
756 : #if !(((defined _WIN32 && !defined __CYGWIN__) || 1) && 1) || 0
757 : # if !GNULIB_defined_mbstate_t
758 : # if !(defined _AIX || defined _MSC_VER || defined __OpenBSD__)
759 : typedef int rpl_mbstate_t;
760 : # undef mbstate_t
761 : # define mbstate_t rpl_mbstate_t
762 : # endif
763 : # define GNULIB_defined_mbstate_t 1
764 : # endif
765 : #endif
766 :
767 : /* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
768 : been included yet. */
769 : #if 1
770 : # if (1 && !defined free \
771 : && !(defined __cplusplus && defined GNULIB_NAMESPACE))
772 : /* We can't do '#define free rpl_free' here. */
773 : # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
774 : _GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW;
775 : # else
776 : _GL_EXTERN_C void rpl_free (void *);
777 : # endif
778 : # undef _GL_ATTRIBUTE_DEALLOC_FREE
779 : # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
780 : # else
781 : # if defined _MSC_VER && !defined free
782 : _GL_EXTERN_C
783 : # if defined _DLL
784 : __declspec (dllimport)
785 : # endif
786 : void __cdecl free (void *);
787 : # else
788 : # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
789 : _GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
790 : # else
791 : _GL_EXTERN_C void free (void *);
792 : # endif
793 : # endif
794 : # endif
795 : #else
796 : # if defined _MSC_VER && !defined free
797 : _GL_EXTERN_C
798 : # if defined _DLL
799 : __declspec (dllimport)
800 : # endif
801 : void __cdecl free (void *);
802 : # else
803 : # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
804 : _GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
805 : # else
806 : _GL_EXTERN_C void free (void *);
807 : # endif
808 : # endif
809 : #endif
810 :
811 :
812 : #if 1
813 : /* Get memset(). */
814 : # include <string.h>
815 : #endif
816 :
817 :
818 : /* Declarations for ISO C N3322. */
819 : #if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
820 : _GL_EXTERN_C wchar_t *wmemcpy (wchar_t *__dest, const wchar_t *__src, size_t __n)
821 : # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
822 : _GL_ATTRIBUTE_NOTHROW
823 : # endif
824 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
825 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
826 : _GL_EXTERN_C wchar_t *wmemmove (wchar_t *__dest, const wchar_t *__src, size_t __n)
827 : # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
828 : _GL_ATTRIBUTE_NOTHROW
829 : # endif
830 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
831 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
832 : _GL_EXTERN_C wchar_t *wcsncpy (wchar_t *__dest, const wchar_t *__src, size_t __n)
833 : # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
834 : _GL_ATTRIBUTE_NOTHROW
835 : # endif
836 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
837 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
838 : _GL_EXTERN_C wchar_t *wcsncat (wchar_t *__dest, const wchar_t *__src, size_t __n)
839 : # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
840 : _GL_ATTRIBUTE_NOTHROW
841 : # endif
842 : _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
843 : _GL_EXTERN_C int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
844 : # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
845 : _GL_ATTRIBUTE_NOTHROW
846 : # endif
847 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
848 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
849 : _GL_EXTERN_C int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
850 : # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
851 : _GL_ATTRIBUTE_NOTHROW
852 : # endif
853 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
854 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
855 : # ifndef __cplusplus
856 : _GL_EXTERN_C wchar_t *wmemchr (const wchar_t *__s, wchar_t __wc, size_t __n)
857 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
858 : # endif
859 : _GL_EXTERN_C wchar_t *wmemset (wchar_t *__s, wchar_t __wc, size_t __n)
860 : # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
861 : _GL_ATTRIBUTE_NOTHROW
862 : # endif
863 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
864 : #endif
865 :
866 :
867 : /* Convert a single-byte character to a wide character. */
868 : #if 0
869 : # if 0
870 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
871 : # undef btowc
872 : # define btowc rpl_btowc
873 : # endif
874 : _GL_FUNCDECL_RPL (btowc, wint_t, (int c), _GL_ATTRIBUTE_PURE);
875 : _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
876 : # else
877 : # if !1
878 : _GL_FUNCDECL_SYS (btowc, wint_t, (int c), _GL_ATTRIBUTE_PURE);
879 : # endif
880 : /* Need to cast, because on mingw, the return type is 'unsigned short'. */
881 : _GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c));
882 : # endif
883 : # if __GLIBC__ >= 2
884 : _GL_CXXALIASWARN (btowc);
885 : # endif
886 : #elif defined GNULIB_POSIXCHECK
887 : # undef btowc
888 : # if HAVE_RAW_DECL_BTOWC
889 : _GL_WARN_ON_USE (btowc, "btowc is unportable - "
890 : "use gnulib module btowc for portability");
891 : # endif
892 : #endif
893 :
894 :
895 : /* Convert a wide character to a single-byte character. */
896 : #if 0
897 : # if 0
898 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
899 : # undef wctob
900 : # define wctob rpl_wctob
901 : # endif
902 : _GL_FUNCDECL_RPL (wctob, int, (wint_t wc), _GL_ATTRIBUTE_PURE);
903 : _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
904 : # else
905 : # if !defined wctob && !1
906 : /* wctob is provided by gnulib, or wctob exists but is not declared. */
907 : _GL_FUNCDECL_SYS (wctob, int, (wint_t wc), _GL_ATTRIBUTE_PURE);
908 : # endif
909 : _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
910 : # endif
911 : # if __GLIBC__ >= 2
912 : _GL_CXXALIASWARN (wctob);
913 : # endif
914 : #elif defined GNULIB_POSIXCHECK
915 : # undef wctob
916 : # if HAVE_RAW_DECL_WCTOB
917 : _GL_WARN_ON_USE (wctob, "wctob is unportable - "
918 : "use gnulib module wctob for portability");
919 : # endif
920 : #endif
921 :
922 :
923 : /* Test whether *PS is in an initial state. */
924 : #if 1
925 : # if 0
926 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
927 : # undef mbsinit
928 : # define mbsinit rpl_mbsinit
929 : # endif
930 : _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps), );
931 : _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
932 : # else
933 : # if !1
934 : _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps), );
935 : # endif
936 : _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
937 : # endif
938 : # if __GLIBC__ >= 2
939 : _GL_CXXALIASWARN (mbsinit);
940 : # endif
941 : #elif defined GNULIB_POSIXCHECK
942 : # undef mbsinit
943 : # if HAVE_RAW_DECL_MBSINIT
944 : _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
945 : "use gnulib module mbsinit for portability");
946 : # endif
947 : #endif
948 :
949 :
950 : /* Put *PS into an initial state. */
951 : #if 1
952 : /* ISO C 23 § 7.31.6.(3) says that zeroing an mbstate_t is a way to put the
953 : mbstate_t into an initial state. However, on many platforms an mbstate_t
954 : is large, and it is possible - as an optimization - to get away with zeroing
955 : only part of it. So, instead of
956 :
957 : mbstate_t state = { 0 };
958 :
959 : or
960 :
961 : mbstate_t state;
962 : memset (&state, 0, sizeof (mbstate_t));
963 :
964 : we can write this faster code:
965 :
966 : mbstate_t state;
967 : mbszero (&state);
968 : */
969 : /* _GL_MBSTATE_INIT_SIZE describes how mbsinit() behaves: It is the number of
970 : bytes at the beginning of an mbstate_t that need to be zero, for mbsinit()
971 : to return true.
972 : _GL_MBSTATE_ZERO_SIZE is the number of bytes at the beginning of an mbstate_t
973 : that need to be zero,
974 : - for mbsinit() to return true, and
975 : - for all other multibyte-aware functions to operate properly.
976 : 0 < _GL_MBSTATE_INIT_SIZE <= _GL_MBSTATE_ZERO_SIZE <= sizeof (mbstate_t).
977 : These values are determined by source code inspection, where possible, and
978 : by running the gnulib unit tests.
979 : We need _GL_MBSTATE_INIT_SIZE because if we define _GL_MBSTATE_ZERO_SIZE
980 : without considering what mbsinit() does, we get test failures such as
981 : assertion "mbsinit (&iter->state)" failed
982 : */
983 : # if GNULIB_defined_mbstate_t /* AIX, IRIX */
984 : /* mbstate_t has at least 4 bytes. They are used as coded in
985 : gnulib/lib/mbrtowc.c. */
986 : # define _GL_MBSTATE_INIT_SIZE 1
987 : /* define _GL_MBSTATE_ZERO_SIZE 4
988 : does not work: it causes test failures.
989 : So, use the safe fallback value, below. */
990 : # elif __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 /* glibc */
991 : /* mbstate_t is defined in <bits/types/__mbstate_t.h>.
992 : For more details, see glibc/iconv/skeleton.c. */
993 : # define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (((mbstate_t) {0}).__count) */
994 : # define _GL_MBSTATE_ZERO_SIZE /* 8 */ sizeof (mbstate_t)
995 : # elif defined MUSL_LIBC /* musl libc */
996 : /* mbstate_t is defined in <bits/alltypes.h>.
997 : It is an opaque aligned 8-byte struct, of which at most the first
998 : 4 bytes are used.
999 : For more details, see src/multibyte/mbrtowc.c. */
1000 : # define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (unsigned) */
1001 : # define _GL_MBSTATE_ZERO_SIZE 4
1002 : # elif defined __APPLE__ && defined __MACH__ /* macOS */
1003 : /* On macOS, mbstate_t is defined in <machine/_types.h>.
1004 : It is an opaque aligned 128-byte struct, of which at most the first
1005 : 12 bytes are used.
1006 : For more details, see the __mbsinit implementations in
1007 : Libc-<version>/locale/FreeBSD/
1008 : {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8,utf2}.c. */
1009 : /* File INIT_SIZE ZERO_SIZE
1010 : ascii.c 0 0
1011 : none.c 0 0
1012 : euc.c 12 12
1013 : mskanji.c 4 4
1014 : big5.c 4 4
1015 : gb2312.c 4 6
1016 : gbk.c 4 4
1017 : gb18030.c 4 8
1018 : utf8.c 8 10
1019 : utf2.c 8 12 */
1020 : # define _GL_MBSTATE_INIT_SIZE 12
1021 : # define _GL_MBSTATE_ZERO_SIZE 12
1022 : # elif defined __FreeBSD__ /* FreeBSD */
1023 : /* On FreeBSD, mbstate_t is defined in src/sys/sys/_types.h.
1024 : It is an opaque aligned 128-byte struct, of which at most the first
1025 : 12 bytes are used.
1026 : For more details, see the __mbsinit implementations in
1027 : src/lib/libc/locale/
1028 : {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
1029 : /* File INIT_SIZE ZERO_SIZE
1030 : ascii.c 0 0
1031 : none.c 0 0
1032 : euc.c 12 12
1033 : mskanji.c 4 4
1034 : big5.c 4 4
1035 : gb2312.c 4 6
1036 : gbk.c 4 4
1037 : gb18030.c 4 8
1038 : utf8.c 8 12 */
1039 : # define _GL_MBSTATE_INIT_SIZE 12
1040 : # define _GL_MBSTATE_ZERO_SIZE 12
1041 : # elif defined __NetBSD__ /* NetBSD */
1042 : /* On NetBSD, mbstate_t is defined in src/sys/sys/ansi.h.
1043 : It is an opaque aligned 128-byte struct, of which at most the first
1044 : 28 bytes are used.
1045 : For more details, see the *State types in
1046 : src/lib/libc/citrus/modules/citrus_*.c
1047 : (ignoring citrus_{hz,iso2022,utf7,viqr,zw}.c, since these implement
1048 : stateful encodings, not usable as locale encodings). */
1049 : /* File ZERO_SIZE
1050 : citrus/citrus_none.c 0
1051 : citrus/modules/citrus_euc.c 8
1052 : citrus/modules/citrus_euctw.c 8
1053 : citrus/modules/citrus_mskanji.c 8
1054 : citrus/modules/citrus_big5.c 8
1055 : citrus/modules/citrus_gbk2k.c 8
1056 : citrus/modules/citrus_dechanyu.c 8
1057 : citrus/modules/citrus_johab.c 6
1058 : citrus/modules/citrus_utf8.c 12 */
1059 : /* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
1060 : failures for values < 28. */
1061 : # define _GL_MBSTATE_ZERO_SIZE 28
1062 : # elif defined __OpenBSD__ /* OpenBSD */
1063 : /* On OpenBSD, mbstate_t is defined in src/sys/sys/_types.h.
1064 : It is an opaque aligned 128-byte struct, of which at most the first
1065 : 12 bytes are used.
1066 : For more details, see src/lib/libc/citrus/citrus_*.c. */
1067 : /* File INIT_SIZE ZERO_SIZE
1068 : citrus_none.c 0 0
1069 : citrus_utf8.c 12 12 */
1070 : # define _GL_MBSTATE_INIT_SIZE 12
1071 : # define _GL_MBSTATE_ZERO_SIZE 12
1072 : # elif defined __minix /* Minix */
1073 : /* On Minix, mbstate_t is defined in sys/sys/ansi.h.
1074 : It is an opaque aligned 128-byte struct.
1075 : For more details, see the *State types in
1076 : lib/libc/citrus/citrus_*.c. */
1077 : /* File INIT_SIZE ZERO_SIZE
1078 : citrus_none.c 0 0 */
1079 : /* But 1 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
1080 : failures for values < 4. */
1081 : # define _GL_MBSTATE_ZERO_SIZE 4
1082 : # elif defined __sun /* Solaris */
1083 : /* On Solaris, mbstate_t is defined in <wchar_impl.h>.
1084 : It is an opaque aligned 24-byte or 32-byte struct, of which at most the first
1085 : 20 or 28 bytes are used.
1086 : For more details on OpenSolaris derivatives, see the *State types in
1087 : illumos-gate/usr/src/lib/libc/port/locale/
1088 : {none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
1089 : /* File INIT_SIZE ZERO_SIZE
1090 : none.c 0 0
1091 : euc.c 12 12
1092 : mskanji.c 4 4
1093 : big5.c 4 4
1094 : gb2312.c 4 6
1095 : gbk.c 4 4
1096 : gb18030.c 4 8
1097 : utf8.c 12 12 */
1098 : /* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
1099 : failures
1100 : - in OpenIndiana and OmniOS: for values < 16,
1101 : - in Solaris 10 and 11: for values < 20 (in 32-bit mode)
1102 : or < 28 (in 64-bit mode).
1103 : Since we don't have a good way to distinguish the OpenSolaris derivatives
1104 : from the proprietary Solaris versions, and can't inspect the Solaris source
1105 : code, use the safe fallback values, below. */
1106 : # elif defined __CYGWIN__ /* Cygwin */
1107 : /* On Cygwin, mbstate_t is defined in <sys/_types.h>.
1108 : For more details, see newlib/libc/stdlib/mbtowc_r.c and
1109 : winsup/cygwin/strfuncs.cc. */
1110 : # define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (int) */
1111 : # define _GL_MBSTATE_ZERO_SIZE 8
1112 : # elif defined _WIN32 && !defined __CYGWIN__ /* Native Windows. */
1113 : /* MSVC defines 'mbstate_t' as an aligned 8-byte struct.
1114 : On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined
1115 : as an aligned 8-byte struct, of which the first 4 bytes matter.
1116 : Use the safe values, below. */
1117 : # elif defined __ANDROID__ /* Android */
1118 : /* Android defines 'mbstate_t' in <bits/mbstate_t.h>.
1119 : It is an opaque 4-byte or 8-byte struct.
1120 : For more details, see
1121 : bionic/libc/private/bionic_mbstate.h
1122 : bionic/libc/bionic/mbrtoc32.cpp
1123 : bionic/libc/bionic/mbrtoc16.cpp
1124 : */
1125 : # define _GL_MBSTATE_INIT_SIZE 4
1126 : # define _GL_MBSTATE_ZERO_SIZE 4
1127 : # endif
1128 : /* Use safe values as defaults. */
1129 : # ifndef _GL_MBSTATE_INIT_SIZE
1130 : # define _GL_MBSTATE_INIT_SIZE sizeof (mbstate_t)
1131 : # endif
1132 : # ifndef _GL_MBSTATE_ZERO_SIZE
1133 : # define _GL_MBSTATE_ZERO_SIZE sizeof (mbstate_t)
1134 : # endif
1135 : _GL_BEGIN_C_LINKAGE
1136 : # if !GNULIB_defined_mbszero
1137 : # if defined IN_MBSZERO
1138 : _GL_EXTERN_INLINE
1139 : # else
1140 : _GL_INLINE
1141 : # endif
1142 : _GL_ARG_NONNULL ((1)) void
1143 0 : mbszero (mbstate_t *ps)
1144 : {
1145 0 : memset (ps, 0, _GL_MBSTATE_ZERO_SIZE);
1146 0 : }
1147 : # define GNULIB_defined_mbszero 1
1148 : # endif
1149 : _GL_END_C_LINKAGE
1150 : _GL_CXXALIAS_SYS (mbszero, void, (mbstate_t *ps));
1151 : _GL_CXXALIASWARN (mbszero);
1152 : #endif
1153 :
1154 :
1155 : /* Convert a multibyte character to a wide character. */
1156 : #if 1
1157 : # if 1
1158 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1159 : # undef mbrtowc
1160 : # define mbrtowc rpl_mbrtowc
1161 : # endif
1162 : _GL_FUNCDECL_RPL (mbrtowc, size_t,
1163 : (wchar_t *restrict pwc, const char *restrict s, size_t n,
1164 : mbstate_t *restrict ps), );
1165 : _GL_CXXALIAS_RPL (mbrtowc, size_t,
1166 : (wchar_t *restrict pwc, const char *restrict s, size_t n,
1167 : mbstate_t *restrict ps));
1168 : # else
1169 : # if !1
1170 : _GL_FUNCDECL_SYS (mbrtowc, size_t,
1171 : (wchar_t *restrict pwc, const char *restrict s, size_t n,
1172 : mbstate_t *restrict ps), );
1173 : # endif
1174 : _GL_CXXALIAS_SYS (mbrtowc, size_t,
1175 : (wchar_t *restrict pwc, const char *restrict s, size_t n,
1176 : mbstate_t *restrict ps));
1177 : # endif
1178 : # if __GLIBC__ >= 2
1179 : _GL_CXXALIASWARN (mbrtowc);
1180 : # endif
1181 : #elif defined GNULIB_POSIXCHECK
1182 : # undef mbrtowc
1183 : # if HAVE_RAW_DECL_MBRTOWC
1184 : _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
1185 : "use gnulib module mbrtowc for portability");
1186 : # endif
1187 : #endif
1188 :
1189 :
1190 : /* Recognize a multibyte character. */
1191 : #if 0
1192 : # if 0
1193 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1194 : # undef mbrlen
1195 : # define mbrlen rpl_mbrlen
1196 : # endif
1197 : _GL_FUNCDECL_RPL (mbrlen, size_t,
1198 : (const char *restrict s, size_t n, mbstate_t *restrict ps), );
1199 : _GL_CXXALIAS_RPL (mbrlen, size_t,
1200 : (const char *restrict s, size_t n, mbstate_t *restrict ps));
1201 : # else
1202 : # if !1
1203 : _GL_FUNCDECL_SYS (mbrlen, size_t,
1204 : (const char *restrict s, size_t n, mbstate_t *restrict ps), );
1205 : # endif
1206 : _GL_CXXALIAS_SYS (mbrlen, size_t,
1207 : (const char *restrict s, size_t n, mbstate_t *restrict ps));
1208 : # endif
1209 : # if __GLIBC__ >= 2
1210 : _GL_CXXALIASWARN (mbrlen);
1211 : # endif
1212 : #elif defined GNULIB_POSIXCHECK
1213 : # undef mbrlen
1214 : # if HAVE_RAW_DECL_MBRLEN
1215 : _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
1216 : "use gnulib module mbrlen for portability");
1217 : # endif
1218 : #endif
1219 :
1220 :
1221 : /* Convert a string to a wide string. */
1222 : #if 0
1223 : # if 0
1224 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1225 : # undef mbsrtowcs
1226 : # define mbsrtowcs rpl_mbsrtowcs
1227 : # endif
1228 : _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
1229 : (wchar_t *restrict dest,
1230 : const char **restrict srcp, size_t len,
1231 : mbstate_t *restrict ps),
1232 : _GL_ARG_NONNULL ((2)));
1233 : _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
1234 : (wchar_t *restrict dest,
1235 : const char **restrict srcp, size_t len,
1236 : mbstate_t *restrict ps));
1237 : # else
1238 : # if !1
1239 : _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
1240 : (wchar_t *restrict dest,
1241 : const char **restrict srcp, size_t len,
1242 : mbstate_t *restrict ps),
1243 : _GL_ARG_NONNULL ((2)));
1244 : # endif
1245 : _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
1246 : (wchar_t *restrict dest,
1247 : const char **restrict srcp, size_t len,
1248 : mbstate_t *restrict ps));
1249 : # endif
1250 : # if __GLIBC__ >= 2
1251 : _GL_CXXALIASWARN (mbsrtowcs);
1252 : # endif
1253 : #elif defined GNULIB_POSIXCHECK
1254 : # undef mbsrtowcs
1255 : # if HAVE_RAW_DECL_MBSRTOWCS
1256 : _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
1257 : "use gnulib module mbsrtowcs for portability");
1258 : # endif
1259 : #endif
1260 :
1261 :
1262 : /* Convert a string to a wide string. */
1263 : #if 0
1264 : # if 0
1265 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1266 : # undef mbsnrtowcs
1267 : # define mbsnrtowcs rpl_mbsnrtowcs
1268 : # endif
1269 : _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
1270 : (wchar_t *restrict dest,
1271 : const char **restrict srcp, size_t srclen, size_t len,
1272 : mbstate_t *restrict ps),
1273 : _GL_ARG_NONNULL ((2)));
1274 : _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
1275 : (wchar_t *restrict dest,
1276 : const char **restrict srcp, size_t srclen, size_t len,
1277 : mbstate_t *restrict ps));
1278 : # else
1279 : # if !1
1280 : _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
1281 : (wchar_t *restrict dest,
1282 : const char **restrict srcp, size_t srclen, size_t len,
1283 : mbstate_t *restrict ps),
1284 : _GL_ARG_NONNULL ((2)));
1285 : # endif
1286 : _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
1287 : (wchar_t *restrict dest,
1288 : const char **restrict srcp, size_t srclen, size_t len,
1289 : mbstate_t *restrict ps));
1290 : # endif
1291 : # if __GLIBC__ >= 2
1292 : _GL_CXXALIASWARN (mbsnrtowcs);
1293 : # endif
1294 : #elif defined GNULIB_POSIXCHECK
1295 : # undef mbsnrtowcs
1296 : # if HAVE_RAW_DECL_MBSNRTOWCS
1297 : _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
1298 : "use gnulib module mbsnrtowcs for portability");
1299 : # endif
1300 : #endif
1301 :
1302 :
1303 : /* Convert a wide character to a multibyte character. */
1304 : #if 0
1305 : # if 0
1306 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1307 : # undef wcrtomb
1308 : # define wcrtomb rpl_wcrtomb
1309 : # endif
1310 : _GL_FUNCDECL_RPL (wcrtomb, size_t,
1311 : (char *restrict s, wchar_t wc, mbstate_t *restrict ps), );
1312 : _GL_CXXALIAS_RPL (wcrtomb, size_t,
1313 : (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
1314 : # else
1315 : # if !1
1316 : _GL_FUNCDECL_SYS (wcrtomb, size_t,
1317 : (char *restrict s, wchar_t wc, mbstate_t *restrict ps), );
1318 : # endif
1319 : _GL_CXXALIAS_SYS (wcrtomb, size_t,
1320 : (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
1321 : # endif
1322 : # if __GLIBC__ >= 2
1323 : _GL_CXXALIASWARN (wcrtomb);
1324 : # endif
1325 : #elif defined GNULIB_POSIXCHECK
1326 : # undef wcrtomb
1327 : # if HAVE_RAW_DECL_WCRTOMB
1328 : _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
1329 : "use gnulib module wcrtomb for portability");
1330 : # endif
1331 : #endif
1332 :
1333 :
1334 : /* Convert a wide string to a string. */
1335 : #if 0
1336 : # if 0
1337 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1338 : # undef wcsrtombs
1339 : # define wcsrtombs rpl_wcsrtombs
1340 : # endif
1341 : _GL_FUNCDECL_RPL (wcsrtombs, size_t,
1342 : (char *restrict dest, const wchar_t **restrict srcp,
1343 : size_t len,
1344 : mbstate_t *restrict ps),
1345 : _GL_ARG_NONNULL ((2)));
1346 : _GL_CXXALIAS_RPL (wcsrtombs, size_t,
1347 : (char *restrict dest, const wchar_t **restrict srcp,
1348 : size_t len,
1349 : mbstate_t *restrict ps));
1350 : # else
1351 : # if !1
1352 : _GL_FUNCDECL_SYS (wcsrtombs, size_t,
1353 : (char *restrict dest, const wchar_t **restrict srcp,
1354 : size_t len,
1355 : mbstate_t *restrict ps),
1356 : _GL_ARG_NONNULL ((2)));
1357 : # endif
1358 : _GL_CXXALIAS_SYS (wcsrtombs, size_t,
1359 : (char *restrict dest, const wchar_t **restrict srcp,
1360 : size_t len,
1361 : mbstate_t *restrict ps));
1362 : # endif
1363 : # if __GLIBC__ >= 2
1364 : _GL_CXXALIASWARN (wcsrtombs);
1365 : # endif
1366 : #elif defined GNULIB_POSIXCHECK
1367 : # undef wcsrtombs
1368 : # if HAVE_RAW_DECL_WCSRTOMBS
1369 : _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
1370 : "use gnulib module wcsrtombs for portability");
1371 : # endif
1372 : #endif
1373 :
1374 :
1375 : /* Convert a wide string to a string. */
1376 : #if 0
1377 : # if 0
1378 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1379 : # undef wcsnrtombs
1380 : # define wcsnrtombs rpl_wcsnrtombs
1381 : # endif
1382 : _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
1383 : (char *restrict dest,
1384 : const wchar_t **restrict srcp, size_t srclen,
1385 : size_t len,
1386 : mbstate_t *restrict ps),
1387 : _GL_ARG_NONNULL ((2)));
1388 : _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
1389 : (char *restrict dest,
1390 : const wchar_t **restrict srcp, size_t srclen,
1391 : size_t len,
1392 : mbstate_t *restrict ps));
1393 : # else
1394 : # if !1 || (defined __cplusplus && defined __sun)
1395 : _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
1396 : (char *restrict dest,
1397 : const wchar_t **restrict srcp, size_t srclen,
1398 : size_t len,
1399 : mbstate_t *restrict ps),
1400 : _GL_ARG_NONNULL ((2)));
1401 : # endif
1402 : _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
1403 : (char *restrict dest,
1404 : const wchar_t **restrict srcp, size_t srclen,
1405 : size_t len,
1406 : mbstate_t *restrict ps));
1407 : # endif
1408 : # if __GLIBC__ >= 2
1409 : _GL_CXXALIASWARN (wcsnrtombs);
1410 : # endif
1411 : #elif defined GNULIB_POSIXCHECK
1412 : # undef wcsnrtombs
1413 : # if HAVE_RAW_DECL_WCSNRTOMBS
1414 : _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
1415 : "use gnulib module wcsnrtombs for portability");
1416 : # endif
1417 : #endif
1418 :
1419 :
1420 : /* Return the number of screen columns needed for WC. */
1421 : #if 1
1422 : # if 0
1423 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1424 : # undef wcwidth
1425 : # define wcwidth rpl_wcwidth
1426 : # endif
1427 : _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t), _GL_ATTRIBUTE_PURE);
1428 : _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
1429 : # else
1430 : # if !1
1431 : /* wcwidth exists but is not declared. */
1432 : _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t), _GL_ATTRIBUTE_PURE);
1433 : # endif
1434 : _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
1435 : # endif
1436 : # if __GLIBC__ >= 2
1437 : _GL_CXXALIASWARN (wcwidth);
1438 : # endif
1439 : #elif defined GNULIB_POSIXCHECK
1440 : # undef wcwidth
1441 : # if HAVE_RAW_DECL_WCWIDTH
1442 : _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
1443 : "use gnulib module wcwidth for portability");
1444 : # endif
1445 : #endif
1446 :
1447 :
1448 : /* Search N wide characters of S for C. */
1449 : #if 0
1450 : # if !1
1451 : _GL_FUNCDECL_SYS (wmemchr, wchar_t *,
1452 : (const wchar_t *s, wchar_t c, size_t n),
1453 : _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
1454 : # endif
1455 : /* On some systems, this function is defined as an overloaded function:
1456 : extern "C++" {
1457 : const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
1458 : wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
1459 : } */
1460 : _GL_CXXALIAS_SYS_CAST2 (wmemchr,
1461 : wchar_t *, (const wchar_t *, wchar_t, size_t),
1462 : const wchar_t *, (const wchar_t *, wchar_t, size_t));
1463 : # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1464 : && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1465 : && !defined __clang__
1466 : _GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
1467 : _GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
1468 : (const wchar_t *s, wchar_t c, size_t n));
1469 : # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1470 : _GL_CXXALIASWARN (wmemchr);
1471 : # endif
1472 : #elif defined GNULIB_POSIXCHECK
1473 : # undef wmemchr
1474 : # if HAVE_RAW_DECL_WMEMCHR
1475 : _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
1476 : "use gnulib module wmemchr for portability");
1477 : # endif
1478 : #endif
1479 :
1480 :
1481 : /* Compare N wide characters of S1 and S2. */
1482 : #if 0
1483 : # if 0
1484 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1485 : # undef wmemcmp
1486 : # define wmemcmp rpl_wmemcmp
1487 : # endif
1488 : _GL_FUNCDECL_RPL (wmemcmp, int,
1489 : (const wchar_t *s1, const wchar_t *s2, size_t n),
1490 : _GL_ATTRIBUTE_PURE
1491 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1492 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1493 : _GL_CXXALIAS_RPL (wmemcmp, int,
1494 : (const wchar_t *s1, const wchar_t *s2, size_t n));
1495 : # else
1496 : # if !1
1497 : _GL_FUNCDECL_SYS (wmemcmp, int,
1498 : (const wchar_t *s1, const wchar_t *s2, size_t n),
1499 : _GL_ATTRIBUTE_PURE
1500 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1501 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1502 : # endif
1503 : _GL_CXXALIAS_SYS (wmemcmp, int,
1504 : (const wchar_t *s1, const wchar_t *s2, size_t n));
1505 : # endif
1506 : # if __GLIBC__ >= 2
1507 : _GL_CXXALIASWARN (wmemcmp);
1508 : # endif
1509 : #elif defined GNULIB_POSIXCHECK
1510 : # undef wmemcmp
1511 : # if HAVE_RAW_DECL_WMEMCMP
1512 : _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
1513 : "use gnulib module wmemcmp for portability");
1514 : # endif
1515 : #endif
1516 :
1517 :
1518 : /* Copy N wide characters of SRC to DEST. */
1519 : #if 0
1520 : # if !1
1521 : _GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
1522 : (wchar_t *restrict dest,
1523 : const wchar_t *restrict src, size_t n),
1524 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1525 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1526 : # endif
1527 : _GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
1528 : (wchar_t *restrict dest,
1529 : const wchar_t *restrict src, size_t n));
1530 : # if __GLIBC__ >= 2
1531 : _GL_CXXALIASWARN (wmemcpy);
1532 : # endif
1533 : #elif defined GNULIB_POSIXCHECK
1534 : # undef wmemcpy
1535 : # if HAVE_RAW_DECL_WMEMCPY
1536 : _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
1537 : "use gnulib module wmemcpy for portability");
1538 : # endif
1539 : #endif
1540 :
1541 :
1542 : /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
1543 : overlapping memory areas. */
1544 : #if 0
1545 : # if !1
1546 : _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
1547 : (wchar_t *dest, const wchar_t *src, size_t n),
1548 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1549 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1550 : # endif
1551 : _GL_CXXALIAS_SYS (wmemmove, wchar_t *,
1552 : (wchar_t *dest, const wchar_t *src, size_t n));
1553 : # if __GLIBC__ >= 2
1554 : _GL_CXXALIASWARN (wmemmove);
1555 : # endif
1556 : #elif defined GNULIB_POSIXCHECK
1557 : # undef wmemmove
1558 : # if HAVE_RAW_DECL_WMEMMOVE
1559 : _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
1560 : "use gnulib module wmemmove for portability");
1561 : # endif
1562 : #endif
1563 :
1564 :
1565 : /* Copy N wide characters of SRC to DEST.
1566 : Return pointer to wide characters after the last written wide character. */
1567 : #if 0
1568 : # if 0
1569 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1570 : # undef wmempcpy
1571 : # define wmempcpy rpl_wmempcpy
1572 : # endif
1573 : _GL_FUNCDECL_RPL (wmempcpy, wchar_t *,
1574 : (wchar_t *restrict dest,
1575 : const wchar_t *restrict src, size_t n), );
1576 : _GL_CXXALIAS_RPL (wmempcpy, wchar_t *,
1577 : (wchar_t *restrict dest,
1578 : const wchar_t *restrict src, size_t n));
1579 : # else
1580 : # if !1
1581 : _GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
1582 : (wchar_t *restrict dest,
1583 : const wchar_t *restrict src, size_t n), );
1584 : # endif
1585 : _GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
1586 : (wchar_t *restrict dest,
1587 : const wchar_t *restrict src, size_t n));
1588 : # endif
1589 : # if __GLIBC__ >= 2
1590 : _GL_CXXALIASWARN (wmempcpy);
1591 : # endif
1592 : #elif defined GNULIB_POSIXCHECK
1593 : # undef wmempcpy
1594 : # if HAVE_RAW_DECL_WMEMPCPY
1595 : _GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
1596 : "use gnulib module wmempcpy for portability");
1597 : # endif
1598 : #endif
1599 :
1600 :
1601 : /* Set N wide characters of S to C. */
1602 : #if 0
1603 : # if !1
1604 : _GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n),
1605 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
1606 : # endif
1607 : _GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
1608 : # if __GLIBC__ >= 2
1609 : _GL_CXXALIASWARN (wmemset);
1610 : # endif
1611 : #elif defined GNULIB_POSIXCHECK
1612 : # undef wmemset
1613 : # if HAVE_RAW_DECL_WMEMSET
1614 : _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
1615 : "use gnulib module wmemset for portability");
1616 : # endif
1617 : #endif
1618 :
1619 :
1620 : /* Return the number of wide characters in S. */
1621 : #if 0
1622 : # if !1
1623 : _GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s), _GL_ATTRIBUTE_PURE);
1624 : # endif
1625 : _GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
1626 : # if __GLIBC__ >= 2
1627 : _GL_CXXALIASWARN (wcslen);
1628 : # endif
1629 : #elif defined GNULIB_POSIXCHECK
1630 : # undef wcslen
1631 : # if HAVE_RAW_DECL_WCSLEN
1632 : _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
1633 : "use gnulib module wcslen for portability");
1634 : # endif
1635 : #endif
1636 :
1637 :
1638 : /* Return the number of wide characters in S, but at most MAXLEN. */
1639 : #if 0
1640 : /* On Solaris 11.3, the header files declare the function in the std::
1641 : namespace, not in the global namespace. So, force a declaration in
1642 : the global namespace. */
1643 : # if !1 || (defined __sun && defined __cplusplus)
1644 : _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen),
1645 : _GL_ATTRIBUTE_PURE);
1646 : # endif
1647 : _GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
1648 : _GL_CXXALIASWARN (wcsnlen);
1649 : #elif defined GNULIB_POSIXCHECK
1650 : # undef wcsnlen
1651 : # if HAVE_RAW_DECL_WCSNLEN
1652 : _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
1653 : "use gnulib module wcsnlen for portability");
1654 : # endif
1655 : #endif
1656 :
1657 :
1658 : /* Copy SRC to DEST. */
1659 : #if 0
1660 : # if !1
1661 : _GL_FUNCDECL_SYS (wcscpy, wchar_t *,
1662 : (wchar_t *restrict dest, const wchar_t *restrict src), );
1663 : # endif
1664 : _GL_CXXALIAS_SYS (wcscpy, wchar_t *,
1665 : (wchar_t *restrict dest, const wchar_t *restrict src));
1666 : # if __GLIBC__ >= 2
1667 : _GL_CXXALIASWARN (wcscpy);
1668 : # endif
1669 : #elif defined GNULIB_POSIXCHECK
1670 : # undef wcscpy
1671 : # if HAVE_RAW_DECL_WCSCPY
1672 : _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
1673 : "use gnulib module wcscpy for portability");
1674 : # endif
1675 : #endif
1676 :
1677 :
1678 : /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
1679 : #if 0
1680 : /* On Solaris 11.3, the header files declare the function in the std::
1681 : namespace, not in the global namespace. So, force a declaration in
1682 : the global namespace. */
1683 : # if !1 || (defined __sun && defined __cplusplus)
1684 : _GL_FUNCDECL_SYS (wcpcpy, wchar_t *,
1685 : (wchar_t *restrict dest, const wchar_t *restrict src), );
1686 : # endif
1687 : _GL_CXXALIAS_SYS (wcpcpy, wchar_t *,
1688 : (wchar_t *restrict dest, const wchar_t *restrict src));
1689 : _GL_CXXALIASWARN (wcpcpy);
1690 : #elif defined GNULIB_POSIXCHECK
1691 : # undef wcpcpy
1692 : # if HAVE_RAW_DECL_WCPCPY
1693 : _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
1694 : "use gnulib module wcpcpy for portability");
1695 : # endif
1696 : #endif
1697 :
1698 :
1699 : /* Copy no more than N wide characters of SRC to DEST. */
1700 : #if 0
1701 : # if !1
1702 : _GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
1703 : (wchar_t *restrict dest,
1704 : const wchar_t *restrict src, size_t n),
1705 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1706 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1707 : # endif
1708 : _GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
1709 : (wchar_t *restrict dest,
1710 : const wchar_t *restrict src, size_t n));
1711 : # if __GLIBC__ >= 2
1712 : _GL_CXXALIASWARN (wcsncpy);
1713 : # endif
1714 : #elif defined GNULIB_POSIXCHECK
1715 : # undef wcsncpy
1716 : # if HAVE_RAW_DECL_WCSNCPY
1717 : _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
1718 : "use gnulib module wcsncpy for portability");
1719 : # endif
1720 : #endif
1721 :
1722 :
1723 : /* Copy no more than N characters of SRC to DEST, returning the address of
1724 : the last character written into DEST. */
1725 : #if 0
1726 : /* On Solaris 11.3, the header files declare the function in the std::
1727 : namespace, not in the global namespace. So, force a declaration in
1728 : the global namespace. */
1729 : # if !1 || (defined __sun && defined __cplusplus)
1730 : _GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
1731 : (wchar_t *restrict dest,
1732 : const wchar_t *restrict src, size_t n), );
1733 : # endif
1734 : _GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
1735 : (wchar_t *restrict dest,
1736 : const wchar_t *restrict src, size_t n));
1737 : _GL_CXXALIASWARN (wcpncpy);
1738 : #elif defined GNULIB_POSIXCHECK
1739 : # undef wcpncpy
1740 : # if HAVE_RAW_DECL_WCPNCPY
1741 : _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
1742 : "use gnulib module wcpncpy for portability");
1743 : # endif
1744 : #endif
1745 :
1746 :
1747 : /* Append SRC onto DEST. */
1748 : #if 0
1749 : # if !1
1750 : _GL_FUNCDECL_SYS (wcscat, wchar_t *,
1751 : (wchar_t *restrict dest, const wchar_t *restrict src), );
1752 : # endif
1753 : _GL_CXXALIAS_SYS (wcscat, wchar_t *,
1754 : (wchar_t *restrict dest, const wchar_t *restrict src));
1755 : # if __GLIBC__ >= 2
1756 : _GL_CXXALIASWARN (wcscat);
1757 : # endif
1758 : #elif defined GNULIB_POSIXCHECK
1759 : # undef wcscat
1760 : # if HAVE_RAW_DECL_WCSCAT
1761 : _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
1762 : "use gnulib module wcscat for portability");
1763 : # endif
1764 : #endif
1765 :
1766 :
1767 : /* Append no more than N wide characters of SRC onto DEST. */
1768 : #if 0
1769 : # if 0
1770 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1771 : # undef wcsncat
1772 : # define wcsncat rpl_wcsncat
1773 : # endif
1774 : _GL_FUNCDECL_RPL (wcsncat, wchar_t *,
1775 : (wchar_t *restrict dest, const wchar_t *restrict src,
1776 : size_t n),
1777 : _GL_ARG_NONNULL ((1))
1778 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1779 : _GL_CXXALIAS_RPL (wcsncat, wchar_t *,
1780 : (wchar_t *restrict dest, const wchar_t *restrict src,
1781 : size_t n));
1782 : # else
1783 : # if !1
1784 : _GL_FUNCDECL_SYS (wcsncat, wchar_t *,
1785 : (wchar_t *restrict dest, const wchar_t *restrict src,
1786 : size_t n),
1787 : _GL_ARG_NONNULL ((1))
1788 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1789 : # endif
1790 : _GL_CXXALIAS_SYS (wcsncat, wchar_t *,
1791 : (wchar_t *restrict dest, const wchar_t *restrict src,
1792 : size_t n));
1793 : # endif
1794 : # if __GLIBC__ >= 2
1795 : _GL_CXXALIASWARN (wcsncat);
1796 : # endif
1797 : #elif defined GNULIB_POSIXCHECK
1798 : # undef wcsncat
1799 : # if HAVE_RAW_DECL_WCSNCAT
1800 : _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
1801 : "use gnulib module wcsncat for portability");
1802 : # endif
1803 : #endif
1804 :
1805 :
1806 : /* Compare S1 and S2. */
1807 : #if 0
1808 : # if 0
1809 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1810 : # undef wcscmp
1811 : # define wcscmp rpl_wcscmp
1812 : # endif
1813 : _GL_FUNCDECL_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2),
1814 : _GL_ATTRIBUTE_PURE);
1815 : _GL_CXXALIAS_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
1816 : # else
1817 : # if !1
1818 : _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2),
1819 : _GL_ATTRIBUTE_PURE);
1820 : # endif
1821 : _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
1822 : # endif
1823 : # if __GLIBC__ >= 2
1824 : _GL_CXXALIASWARN (wcscmp);
1825 : # endif
1826 : #elif defined GNULIB_POSIXCHECK
1827 : # undef wcscmp
1828 : # if HAVE_RAW_DECL_WCSCMP
1829 : _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
1830 : "use gnulib module wcscmp for portability");
1831 : # endif
1832 : #endif
1833 :
1834 :
1835 : /* Compare no more than N wide characters of S1 and S2. */
1836 : #if 0
1837 : # if 0
1838 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1839 : # undef wcsncmp
1840 : # define wcsncmp rpl_wcsncmp
1841 : # endif
1842 : _GL_FUNCDECL_RPL (wcsncmp, int,
1843 : (const wchar_t *s1, const wchar_t *s2, size_t n),
1844 : _GL_ATTRIBUTE_PURE
1845 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1846 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1847 : _GL_CXXALIAS_RPL (wcsncmp, int,
1848 : (const wchar_t *s1, const wchar_t *s2, size_t n));
1849 : # else
1850 : # if !1
1851 : _GL_FUNCDECL_SYS (wcsncmp, int,
1852 : (const wchar_t *s1, const wchar_t *s2, size_t n),
1853 : _GL_ATTRIBUTE_PURE
1854 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1855 : _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1856 : # endif
1857 : _GL_CXXALIAS_SYS (wcsncmp, int,
1858 : (const wchar_t *s1, const wchar_t *s2, size_t n));
1859 : # endif
1860 : # if __GLIBC__ >= 2
1861 : _GL_CXXALIASWARN (wcsncmp);
1862 : # endif
1863 : #elif defined GNULIB_POSIXCHECK
1864 : # undef wcsncmp
1865 : # if HAVE_RAW_DECL_WCSNCMP
1866 : _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
1867 : "use gnulib module wcsncmp for portability");
1868 : # endif
1869 : #endif
1870 :
1871 :
1872 : /* Compare S1 and S2, ignoring case. */
1873 : #if 0
1874 : /* On Solaris 11.3, the header files declare the function in the std::
1875 : namespace, not in the global namespace. So, force a declaration in
1876 : the global namespace. */
1877 : # if !1 || (defined __sun && defined __cplusplus)
1878 : _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2),
1879 : _GL_ATTRIBUTE_PURE);
1880 : # endif
1881 : _GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
1882 : _GL_CXXALIASWARN (wcscasecmp);
1883 : #elif defined GNULIB_POSIXCHECK
1884 : # undef wcscasecmp
1885 : # if HAVE_RAW_DECL_WCSCASECMP
1886 : _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
1887 : "use gnulib module wcscasecmp for portability");
1888 : # endif
1889 : #endif
1890 :
1891 :
1892 : /* Compare no more than N chars of S1 and S2, ignoring case. */
1893 : #if 0
1894 : /* On Solaris 11.3, the header files declare the function in the std::
1895 : namespace, not in the global namespace. So, force a declaration in
1896 : the global namespace. */
1897 : # if !1 || (defined __sun && defined __cplusplus)
1898 : _GL_FUNCDECL_SYS (wcsncasecmp, int,
1899 : (const wchar_t *s1, const wchar_t *s2, size_t n),
1900 : _GL_ATTRIBUTE_PURE);
1901 : # endif
1902 : _GL_CXXALIAS_SYS (wcsncasecmp, int,
1903 : (const wchar_t *s1, const wchar_t *s2, size_t n));
1904 : _GL_CXXALIASWARN (wcsncasecmp);
1905 : #elif defined GNULIB_POSIXCHECK
1906 : # undef wcsncasecmp
1907 : # if HAVE_RAW_DECL_WCSNCASECMP
1908 : _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
1909 : "use gnulib module wcsncasecmp for portability");
1910 : # endif
1911 : #endif
1912 :
1913 :
1914 : /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
1915 : category of the current locale. */
1916 : #if 0
1917 : # if !1
1918 : _GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2), );
1919 : # endif
1920 : _GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
1921 : # if __GLIBC__ >= 2
1922 : _GL_CXXALIASWARN (wcscoll);
1923 : # endif
1924 : #elif defined GNULIB_POSIXCHECK
1925 : # undef wcscoll
1926 : # if HAVE_RAW_DECL_WCSCOLL
1927 : _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
1928 : "use gnulib module wcscoll for portability");
1929 : # endif
1930 : #endif
1931 :
1932 :
1933 : /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
1934 : to two transformed strings the result is the as applying 'wcscoll' to the
1935 : original strings. */
1936 : #if 0
1937 : # if !1
1938 : _GL_FUNCDECL_SYS (wcsxfrm, size_t,
1939 : (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n), );
1940 : # endif
1941 : _GL_CXXALIAS_SYS (wcsxfrm, size_t,
1942 : (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
1943 : # if __GLIBC__ >= 2
1944 : _GL_CXXALIASWARN (wcsxfrm);
1945 : # endif
1946 : #elif defined GNULIB_POSIXCHECK
1947 : # undef wcsxfrm
1948 : # if HAVE_RAW_DECL_WCSXFRM
1949 : _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
1950 : "use gnulib module wcsxfrm for portability");
1951 : # endif
1952 : #endif
1953 :
1954 :
1955 : /* Duplicate S, returning an identical malloc'd string. */
1956 : #if 0
1957 : # if defined _WIN32 && !defined __CYGWIN__
1958 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1959 : # undef wcsdup
1960 : # define wcsdup _wcsdup
1961 : # endif
1962 : _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1963 : # else
1964 : /* On Solaris 11.3, the header files declare the function in the std::
1965 : namespace, not in the global namespace. So, force a declaration in
1966 : the global namespace. */
1967 : # if !1 || (defined __sun && defined __cplusplus) \
1968 : || (__GNUC__ >= 11 && !defined __clang__)
1969 : # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1970 : _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1971 : (const wchar_t *s),
1972 : _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1973 : _GL_ATTRIBUTE_NOTHROW;
1974 : # else
1975 : _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1976 : (const wchar_t *s),
1977 : _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1978 : # endif
1979 : # endif
1980 : _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1981 : # endif
1982 : _GL_CXXALIASWARN (wcsdup);
1983 : #else
1984 : # if (__GNUC__ >= 11 && !defined __clang__) && !defined wcsdup
1985 : /* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */
1986 : # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1987 : _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1988 : (const wchar_t *s),
1989 : _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1990 : _GL_ATTRIBUTE_NOTHROW;
1991 : # else
1992 : _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1993 : (const wchar_t *s),
1994 : _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1995 : # endif
1996 : # endif
1997 : # if defined GNULIB_POSIXCHECK
1998 : # undef wcsdup
1999 : # if HAVE_RAW_DECL_WCSDUP
2000 : _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
2001 : "use gnulib module wcsdup for portability");
2002 : # endif
2003 : # elif 1
2004 : /* On native Windows, map 'wcsdup' to '_wcsdup', so that -loldnames is not
2005 : required. In C++ with GNULIB_NAMESPACE, avoid differences between
2006 : platforms by defining GNULIB_NAMESPACE::wcsdup always. */
2007 : # if defined _WIN32 && !defined __CYGWIN__
2008 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2009 : # undef wcsdup
2010 : # define wcsdup _wcsdup
2011 : # endif
2012 : _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
2013 : # else
2014 : # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
2015 : _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
2016 : (const wchar_t *s),
2017 : _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
2018 : _GL_ATTRIBUTE_NOTHROW;
2019 : # else
2020 : _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
2021 : (const wchar_t *s),
2022 : _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
2023 : # endif
2024 : # if 1
2025 : _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
2026 : # endif
2027 : # endif
2028 : # if (defined _WIN32 && !defined __CYGWIN__) || 1
2029 : _GL_CXXALIASWARN (wcsdup);
2030 : # endif
2031 : # endif
2032 : #endif
2033 :
2034 :
2035 : /* Find the first occurrence of WC in WCS. */
2036 : #if 0
2037 : # if !1
2038 : _GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc),
2039 : _GL_ATTRIBUTE_PURE);
2040 : # endif
2041 : /* On some systems, this function is defined as an overloaded function:
2042 : extern "C++" {
2043 : const wchar_t * std::wcschr (const wchar_t *, wchar_t);
2044 : wchar_t * std::wcschr (wchar_t *, wchar_t);
2045 : } */
2046 : _GL_CXXALIAS_SYS_CAST2 (wcschr,
2047 : wchar_t *, (const wchar_t *, wchar_t),
2048 : const wchar_t *, (const wchar_t *, wchar_t));
2049 : # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
2050 : && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
2051 : && !defined __clang__
2052 : _GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
2053 : _GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
2054 : # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
2055 : _GL_CXXALIASWARN (wcschr);
2056 : # endif
2057 : #elif defined GNULIB_POSIXCHECK
2058 : # undef wcschr
2059 : # if HAVE_RAW_DECL_WCSCHR
2060 : _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
2061 : "use gnulib module wcschr for portability");
2062 : # endif
2063 : #endif
2064 :
2065 :
2066 : /* Find the last occurrence of WC in WCS. */
2067 : #if 0
2068 : # if !1
2069 : _GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc),
2070 : _GL_ATTRIBUTE_PURE);
2071 : # endif
2072 : /* On some systems, this function is defined as an overloaded function:
2073 : extern "C++" {
2074 : const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
2075 : wchar_t * std::wcsrchr (wchar_t *, wchar_t);
2076 : } */
2077 : _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
2078 : wchar_t *, (const wchar_t *, wchar_t),
2079 : const wchar_t *, (const wchar_t *, wchar_t));
2080 : # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
2081 : && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
2082 : && !defined __clang__
2083 : _GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
2084 : _GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
2085 : # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
2086 : _GL_CXXALIASWARN (wcsrchr);
2087 : # endif
2088 : #elif defined GNULIB_POSIXCHECK
2089 : # undef wcsrchr
2090 : # if HAVE_RAW_DECL_WCSRCHR
2091 : _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
2092 : "use gnulib module wcsrchr for portability");
2093 : # endif
2094 : #endif
2095 :
2096 :
2097 : /* Return the length of the initial segment of WCS which consists entirely
2098 : of wide characters not in REJECT. */
2099 : #if 0
2100 : # if !1
2101 : _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject),
2102 : _GL_ATTRIBUTE_PURE);
2103 : # endif
2104 : _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
2105 : # if __GLIBC__ >= 2
2106 : _GL_CXXALIASWARN (wcscspn);
2107 : # endif
2108 : #elif defined GNULIB_POSIXCHECK
2109 : # undef wcscspn
2110 : # if HAVE_RAW_DECL_WCSCSPN
2111 : _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
2112 : "use gnulib module wcscspn for portability");
2113 : # endif
2114 : #endif
2115 :
2116 :
2117 : /* Return the length of the initial segment of WCS which consists entirely
2118 : of wide characters in ACCEPT. */
2119 : #if 0
2120 : # if !1
2121 : _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept),
2122 : _GL_ATTRIBUTE_PURE);
2123 : # endif
2124 : _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
2125 : # if __GLIBC__ >= 2
2126 : _GL_CXXALIASWARN (wcsspn);
2127 : # endif
2128 : #elif defined GNULIB_POSIXCHECK
2129 : # undef wcsspn
2130 : # if HAVE_RAW_DECL_WCSSPN
2131 : _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
2132 : "use gnulib module wcsspn for portability");
2133 : # endif
2134 : #endif
2135 :
2136 :
2137 : /* Find the first occurrence in WCS of any character in ACCEPT. */
2138 : #if 0
2139 : # if !1
2140 : _GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
2141 : (const wchar_t *wcs, const wchar_t *accept),
2142 : _GL_ATTRIBUTE_PURE);
2143 : # endif
2144 : /* On some systems, this function is defined as an overloaded function:
2145 : extern "C++" {
2146 : const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
2147 : wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
2148 : } */
2149 : _GL_CXXALIAS_SYS_CAST2 (wcspbrk,
2150 : wchar_t *, (const wchar_t *, const wchar_t *),
2151 : const wchar_t *, (const wchar_t *, const wchar_t *));
2152 : # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
2153 : && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
2154 : && !defined __clang__
2155 : _GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
2156 : (wchar_t *wcs, const wchar_t *accept));
2157 : _GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
2158 : (const wchar_t *wcs, const wchar_t *accept));
2159 : # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
2160 : _GL_CXXALIASWARN (wcspbrk);
2161 : # endif
2162 : #elif defined GNULIB_POSIXCHECK
2163 : # undef wcspbrk
2164 : # if HAVE_RAW_DECL_WCSPBRK
2165 : _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
2166 : "use gnulib module wcspbrk for portability");
2167 : # endif
2168 : #endif
2169 :
2170 :
2171 : /* Find the first occurrence of NEEDLE in HAYSTACK. */
2172 : #if 0
2173 : # if 0
2174 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2175 : # undef wcsstr
2176 : # define wcsstr rpl_wcsstr
2177 : # endif
2178 : _GL_FUNCDECL_RPL (wcsstr, wchar_t *,
2179 : (const wchar_t *restrict haystack,
2180 : const wchar_t *restrict needle),
2181 : _GL_ATTRIBUTE_PURE);
2182 : _GL_CXXALIAS_RPL (wcsstr, wchar_t *,
2183 : (const wchar_t *restrict haystack,
2184 : const wchar_t *restrict needle));
2185 : # else
2186 : # if !1
2187 : _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
2188 : (const wchar_t *restrict haystack,
2189 : const wchar_t *restrict needle),
2190 : _GL_ATTRIBUTE_PURE);
2191 : # endif
2192 : /* On some systems, this function is defined as an overloaded function:
2193 : extern "C++" {
2194 : const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
2195 : wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
2196 : } */
2197 : _GL_CXXALIAS_SYS_CAST2 (wcsstr,
2198 : wchar_t *,
2199 : (const wchar_t *restrict, const wchar_t *restrict),
2200 : const wchar_t *,
2201 : (const wchar_t *restrict, const wchar_t *restrict));
2202 : # endif
2203 : # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
2204 : && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
2205 : && !defined __clang__
2206 : _GL_CXXALIASWARN1 (wcsstr, wchar_t *,
2207 : (wchar_t *restrict haystack,
2208 : const wchar_t *restrict needle));
2209 : _GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
2210 : (const wchar_t *restrict haystack,
2211 : const wchar_t *restrict needle));
2212 : # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
2213 : _GL_CXXALIASWARN (wcsstr);
2214 : # endif
2215 : #elif defined GNULIB_POSIXCHECK
2216 : # undef wcsstr
2217 : # if HAVE_RAW_DECL_WCSSTR
2218 : _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
2219 : "use gnulib module wcsstr for portability");
2220 : # endif
2221 : #endif
2222 :
2223 :
2224 : /* Divide WCS into tokens separated by characters in DELIM. */
2225 : #if 0
2226 : # if 0
2227 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2228 : # undef wcstok
2229 : # define wcstok rpl_wcstok
2230 : # endif
2231 : _GL_FUNCDECL_RPL (wcstok, wchar_t *,
2232 : (wchar_t *restrict wcs, const wchar_t *restrict delim,
2233 : wchar_t **restrict ptr), );
2234 : _GL_CXXALIAS_RPL (wcstok, wchar_t *,
2235 : (wchar_t *restrict wcs, const wchar_t *restrict delim,
2236 : wchar_t **restrict ptr));
2237 : # else
2238 : # if !1
2239 : _GL_FUNCDECL_SYS (wcstok, wchar_t *,
2240 : (wchar_t *restrict wcs, const wchar_t *restrict delim,
2241 : wchar_t **restrict ptr), );
2242 : # endif
2243 : _GL_CXXALIAS_SYS (wcstok, wchar_t *,
2244 : (wchar_t *restrict wcs, const wchar_t *restrict delim,
2245 : wchar_t **restrict ptr));
2246 : # endif
2247 : # if __GLIBC__ >= 2
2248 : _GL_CXXALIASWARN (wcstok);
2249 : # endif
2250 : #elif defined GNULIB_POSIXCHECK
2251 : # undef wcstok
2252 : # if HAVE_RAW_DECL_WCSTOK
2253 : _GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
2254 : "use gnulib module wcstok for portability");
2255 : # endif
2256 : #endif
2257 :
2258 :
2259 : /* Determine number of column positions required for first N wide
2260 : characters (or fewer if S ends before this) in S. */
2261 : #if 0
2262 : # if 0
2263 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2264 : # undef wcswidth
2265 : # define wcswidth rpl_wcswidth
2266 : # endif
2267 : _GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n),
2268 : _GL_ATTRIBUTE_PURE);
2269 : _GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
2270 : # else
2271 : # if !1
2272 : _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n),
2273 : _GL_ATTRIBUTE_PURE);
2274 : # endif
2275 : _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
2276 : # endif
2277 : # if __GLIBC__ >= 2
2278 : _GL_CXXALIASWARN (wcswidth);
2279 : # endif
2280 : #elif defined GNULIB_POSIXCHECK
2281 : # undef wcswidth
2282 : # if HAVE_RAW_DECL_WCSWIDTH
2283 : _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
2284 : "use gnulib module wcswidth for portability");
2285 : # endif
2286 : #endif
2287 :
2288 :
2289 : /* Convert *TP to a date and time wide string. See
2290 : <https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
2291 : #if 0
2292 : # if 0
2293 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2294 : # undef wcsftime
2295 : # define wcsftime rpl_wcsftime
2296 : # endif
2297 : _GL_FUNCDECL_RPL (wcsftime, size_t,
2298 : (wchar_t *restrict __buf, size_t __bufsize,
2299 : const wchar_t *restrict __fmt,
2300 : const struct tm *restrict __tp),
2301 : _GL_ARG_NONNULL ((1, 3, 4)));
2302 : _GL_CXXALIAS_RPL (wcsftime, size_t,
2303 : (wchar_t *restrict __buf, size_t __bufsize,
2304 : const wchar_t *restrict __fmt,
2305 : const struct tm *restrict __tp));
2306 : # else
2307 : # if !1
2308 : _GL_FUNCDECL_SYS (wcsftime, size_t,
2309 : (wchar_t *restrict __buf, size_t __bufsize,
2310 : const wchar_t *restrict __fmt,
2311 : const struct tm *restrict __tp),
2312 : _GL_ARG_NONNULL ((1, 3, 4)));
2313 : # endif
2314 : _GL_CXXALIAS_SYS (wcsftime, size_t,
2315 : (wchar_t *restrict __buf, size_t __bufsize,
2316 : const wchar_t *restrict __fmt,
2317 : const struct tm *restrict __tp));
2318 : # endif
2319 : # if __GLIBC__ >= 2
2320 : _GL_CXXALIASWARN (wcsftime);
2321 : # endif
2322 : #elif defined GNULIB_POSIXCHECK
2323 : # undef wcsftime
2324 : # if HAVE_RAW_DECL_WCSFTIME
2325 : _GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
2326 : "use gnulib module wcsftime for portability");
2327 : # endif
2328 : #endif
2329 :
2330 :
2331 : #if 0 && (defined _WIN32 && !defined __CYGWIN__)
2332 : /* Gets the name of the current working directory.
2333 : (a) If BUF is non-NULL, it is assumed to have room for SIZE wide characters.
2334 : This function stores the working directory (NUL-terminated) in BUF and
2335 : returns BUF.
2336 : (b) If BUF is NULL, an array is allocated with 'malloc'. The array is SIZE
2337 : wide characters long, unless SIZE == 0, in which case it is as big as
2338 : necessary.
2339 : If the directory couldn't be determined or SIZE was too small, this function
2340 : returns NULL and sets errno. For a directory of length LEN, SIZE should be
2341 : >= LEN + 3 in case (a) or >= LEN + 1 in case (b).
2342 : Possible errno values include:
2343 : - ERANGE if SIZE is too small.
2344 : - ENOMEM if the memory could no be allocated. */
2345 : _GL_FUNCDECL_SYS (wgetcwd, wchar_t *, (wchar_t *buf, size_t size), );
2346 : #endif
2347 :
2348 :
2349 : #endif /* _GL_WCHAR_H */
2350 : #endif /* _GL_WCHAR_H */
2351 : #endif
|