gettext: Sync with gettext 0.23.
[gnulib.git] / lib / wchar.in.h
blob3c6beb0712300d58b3df8f8012cdc02cdceff138
1 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
3 Copyright (C) 2007-2024 Free Software Foundation, Inc.
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 /* Written by Eric Blake. */
21 * ISO C 99 <wchar.h> for platforms that have issues.
22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wchar.h.html>
24 * For now, this just ensures proper prerequisite inclusion order and
25 * the declaration of wcwidth().
28 #if __GNUC__ >= 3
29 @PRAGMA_SYSTEM_HEADER@
30 #endif
31 @PRAGMA_COLUMNS@
33 #if (((defined __need_mbstate_t || defined __need_wint_t) \
34 && !defined __MINGW32__) \
35 || (defined __hpux \
36 && ((defined _INTTYPES_INCLUDED \
37 && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \
38 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
39 || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
40 || defined _GL_ALREADY_INCLUDING_WCHAR_H)
41 /* Special invocation convention:
42 - Inside glibc and uClibc header files, but not MinGW.
43 - On HP-UX 11.00 we have a sequence of nested includes
44 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
45 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
46 and once directly. In both situations 'wint_t' is not yet defined,
47 therefore we cannot provide the function overrides; instead include only
48 the system's <wchar.h>.
49 - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of
50 <wchar.h> is actually processed, and that doesn't include 'mbstate_t'.
51 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
52 the latter includes <wchar.h>. But here, we have no way to detect whether
53 <wctype.h> is completely included or is still being included. */
55 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
57 #else
58 /* Normal invocation convention. */
60 #ifndef _@GUARD_PREFIX@_WCHAR_H
62 #define _GL_ALREADY_INCLUDING_WCHAR_H
64 #if @HAVE_FEATURES_H@
65 # include <features.h> /* for __GLIBC__ */
66 #endif
68 /* In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
69 by <stddef.h>.
70 But avoid namespace pollution on glibc systems. */
71 #if !(defined __GLIBC__ && !defined __UCLIBC__)
72 # include <stddef.h>
73 #endif
75 /* Include the original <wchar.h> if it exists.
76 Some builds of uClibc lack it. */
77 /* The include_next requires a split double-inclusion guard. */
78 #if @HAVE_WCHAR_H@
79 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
80 #endif
82 #undef _GL_ALREADY_INCLUDING_WCHAR_H
84 #ifndef _@GUARD_PREFIX@_WCHAR_H
85 #define _@GUARD_PREFIX@_WCHAR_H
87 /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
88 _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
89 HAVE_RAW_DECL_*. */
90 #if !_GL_CONFIG_H_INCLUDED
91 #error "Please include config.h first."
92 #endif
94 /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
95 that can be freed by passing them as the Ith argument to the
96 function F. */
97 #ifndef _GL_ATTRIBUTE_DEALLOC
98 # if __GNUC__ >= 11 && !defined __clang__
99 # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
100 # else
101 # define _GL_ATTRIBUTE_DEALLOC(f, i)
102 # endif
103 #endif
105 /* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
106 can be freed via 'free'; it can be used only after declaring 'free'. */
107 /* Applies to: functions. Cannot be used on inline functions. */
108 #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
109 # if defined __cplusplus && defined __GNUC__ && !defined __clang__
110 /* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
111 # define _GL_ATTRIBUTE_DEALLOC_FREE \
112 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
113 # else
114 # define _GL_ATTRIBUTE_DEALLOC_FREE \
115 _GL_ATTRIBUTE_DEALLOC (free, 1)
116 # endif
117 #endif
119 /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
120 allocated memory. */
121 /* Applies to: functions. */
122 #ifndef _GL_ATTRIBUTE_MALLOC
123 # if __GNUC__ >= 3 || defined __clang__
124 # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
125 # else
126 # define _GL_ATTRIBUTE_MALLOC
127 # endif
128 #endif
130 /* The __attribute__ feature is available in gcc versions 2.5 and later.
131 The attribute __pure__ was added in gcc 2.96. */
132 #ifndef _GL_ATTRIBUTE_PURE
133 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
134 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
135 # else
136 # define _GL_ATTRIBUTE_PURE /* empty */
137 # endif
138 #endif
140 /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
142 #ifndef _GL_ATTRIBUTE_NOTHROW
143 # if defined __cplusplus
144 # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
145 # if __cplusplus >= 201103L
146 # define _GL_ATTRIBUTE_NOTHROW noexcept (true)
147 # else
148 # define _GL_ATTRIBUTE_NOTHROW throw ()
149 # endif
150 # else
151 # define _GL_ATTRIBUTE_NOTHROW
152 # endif
153 # else
154 # if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
155 # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
156 # else
157 # define _GL_ATTRIBUTE_NOTHROW
158 # endif
159 # endif
160 #endif
162 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
164 /* The definition of _GL_ARG_NONNULL is copied here. */
166 /* The definition of _GL_WARN_ON_USE is copied here. */
169 /* Define wint_t and WEOF. (Also done in wctype.in.h.) */
170 #if !@HAVE_WINT_T@ && !defined wint_t
171 # define wint_t int
172 # ifndef WEOF
173 # define WEOF -1
174 # endif
175 #else
176 /* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
177 <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
178 wint_t must be "unchanged by default argument promotions". Override it. */
179 # if @GNULIBHEADERS_OVERRIDE_WINT_T@
180 # if !GNULIB_defined_wint_t
181 # if @HAVE_CRTDEFS_H@
182 # include <crtdefs.h>
183 # else
184 # include <stddef.h>
185 # endif
186 typedef unsigned int rpl_wint_t;
187 # undef wint_t
188 # define wint_t rpl_wint_t
189 # define GNULIB_defined_wint_t 1
190 # endif
191 # endif
192 # ifndef WEOF
193 # define WEOF ((wint_t) -1)
194 # endif
195 #endif
198 /* Override mbstate_t if it is too small.
199 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
200 implementing mbrtowc for encodings like UTF-8.
201 On AIX and MSVC, mbrtowc needs to be overridden, but mbstate_t exists and is
202 large enough and overriding it would cause problems in C++ mode. */
203 #if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
204 # if !GNULIB_defined_mbstate_t
205 # if !(defined _AIX || defined _MSC_VER)
206 typedef int rpl_mbstate_t;
207 # undef mbstate_t
208 # define mbstate_t rpl_mbstate_t
209 # endif
210 # define GNULIB_defined_mbstate_t 1
211 # endif
212 #endif
214 /* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
215 been included yet. */
216 #if @GNULIB_FREE_POSIX@
217 # if (@REPLACE_FREE@ && !defined free \
218 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
219 /* We can't do '#define free rpl_free' here. */
220 # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
221 _GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW;
222 # else
223 _GL_EXTERN_C void rpl_free (void *);
224 # endif
225 # undef _GL_ATTRIBUTE_DEALLOC_FREE
226 # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
227 # else
228 # if defined _MSC_VER && !defined free
229 _GL_EXTERN_C
230 # if defined _DLL
231 __declspec (dllimport)
232 # endif
233 void __cdecl free (void *);
234 # else
235 # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
236 _GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
237 # else
238 _GL_EXTERN_C void free (void *);
239 # endif
240 # endif
241 # endif
242 #else
243 # if defined _MSC_VER && !defined free
244 _GL_EXTERN_C
245 # if defined _DLL
246 __declspec (dllimport)
247 # endif
248 void __cdecl free (void *);
249 # else
250 # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
251 _GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
252 # else
253 _GL_EXTERN_C void free (void *);
254 # endif
255 # endif
256 #endif
259 #if @GNULIB_MBSZERO@
260 /* Get memset(). */
261 # include <string.h>
262 #endif
265 /* Convert a single-byte character to a wide character. */
266 #if @GNULIB_BTOWC@
267 # if @REPLACE_BTOWC@
268 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
269 # undef btowc
270 # define btowc rpl_btowc
271 # endif
272 _GL_FUNCDECL_RPL (btowc, wint_t, (int c), _GL_ATTRIBUTE_PURE);
273 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
274 # else
275 # if !@HAVE_BTOWC@
276 _GL_FUNCDECL_SYS (btowc, wint_t, (int c), _GL_ATTRIBUTE_PURE);
277 # endif
278 /* Need to cast, because on mingw, the return type is 'unsigned short'. */
279 _GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c));
280 # endif
281 # if __GLIBC__ >= 2
282 _GL_CXXALIASWARN (btowc);
283 # endif
284 #elif defined GNULIB_POSIXCHECK
285 # undef btowc
286 # if HAVE_RAW_DECL_BTOWC
287 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
288 "use gnulib module btowc for portability");
289 # endif
290 #endif
293 /* Convert a wide character to a single-byte character. */
294 #if @GNULIB_WCTOB@
295 # if @REPLACE_WCTOB@
296 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
297 # undef wctob
298 # define wctob rpl_wctob
299 # endif
300 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc), _GL_ATTRIBUTE_PURE);
301 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
302 # else
303 # if !defined wctob && !@HAVE_DECL_WCTOB@
304 /* wctob is provided by gnulib, or wctob exists but is not declared. */
305 _GL_FUNCDECL_SYS (wctob, int, (wint_t wc), _GL_ATTRIBUTE_PURE);
306 # endif
307 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
308 # endif
309 # if __GLIBC__ >= 2
310 _GL_CXXALIASWARN (wctob);
311 # endif
312 #elif defined GNULIB_POSIXCHECK
313 # undef wctob
314 # if HAVE_RAW_DECL_WCTOB
315 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
316 "use gnulib module wctob for portability");
317 # endif
318 #endif
321 /* Test whether *PS is in an initial state. */
322 #if @GNULIB_MBSINIT@
323 # if @REPLACE_MBSINIT@
324 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
325 # undef mbsinit
326 # define mbsinit rpl_mbsinit
327 # endif
328 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps), );
329 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
330 # else
331 # if !@HAVE_MBSINIT@
332 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps), );
333 # endif
334 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
335 # endif
336 # if __GLIBC__ >= 2
337 _GL_CXXALIASWARN (mbsinit);
338 # endif
339 #elif defined GNULIB_POSIXCHECK
340 # undef mbsinit
341 # if HAVE_RAW_DECL_MBSINIT
342 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
343 "use gnulib module mbsinit for portability");
344 # endif
345 #endif
348 /* Put *PS into an initial state. */
349 #if @GNULIB_MBSZERO@
350 /* ISO C 23 § 7.31.6.(3) says that zeroing an mbstate_t is a way to put the
351 mbstate_t into an initial state. However, on many platforms an mbstate_t
352 is large, and it is possible - as an optimization - to get away with zeroing
353 only part of it. So, instead of
355 mbstate_t state = { 0 };
359 mbstate_t state;
360 memset (&state, 0, sizeof (mbstate_t));
362 we can write this faster code:
364 mbstate_t state;
365 mbszero (&state);
367 /* _GL_MBSTATE_INIT_SIZE describes how mbsinit() behaves: It is the number of
368 bytes at the beginning of an mbstate_t that need to be zero, for mbsinit()
369 to return true.
370 _GL_MBSTATE_ZERO_SIZE is the number of bytes at the beginning of an mbstate_t
371 that need to be zero,
372 - for mbsinit() to return true, and
373 - for all other multibyte-aware functions to operate properly.
374 0 < _GL_MBSTATE_INIT_SIZE <= _GL_MBSTATE_ZERO_SIZE <= sizeof (mbstate_t).
375 These values are determined by source code inspection, where possible, and
376 by running the gnulib unit tests.
377 We need _GL_MBSTATE_INIT_SIZE because if we define _GL_MBSTATE_ZERO_SIZE
378 without considering what mbsinit() does, we get test failures such as
379 assertion "mbsinit (&iter->state)" failed
381 # if GNULIB_defined_mbstate_t /* AIX, IRIX */
382 /* mbstate_t has at least 4 bytes. They are used as coded in
383 gnulib/lib/mbrtowc.c. */
384 # define _GL_MBSTATE_INIT_SIZE 1
385 /* define _GL_MBSTATE_ZERO_SIZE 4
386 does not work: it causes test failures.
387 So, use the safe fallback value, below. */
388 # elif __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 /* glibc */
389 /* mbstate_t is defined in <bits/types/__mbstate_t.h>.
390 For more details, see glibc/iconv/skeleton.c. */
391 # define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (((mbstate_t) {0}).__count) */
392 # define _GL_MBSTATE_ZERO_SIZE /* 8 */ sizeof (mbstate_t)
393 # elif defined MUSL_LIBC /* musl libc */
394 /* mbstate_t is defined in <bits/alltypes.h>.
395 It is an opaque aligned 8-byte struct, of which at most the first
396 4 bytes are used.
397 For more details, see src/multibyte/mbrtowc.c. */
398 # define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (unsigned) */
399 # define _GL_MBSTATE_ZERO_SIZE 4
400 # elif defined __APPLE__ && defined __MACH__ /* macOS */
401 /* On macOS, mbstate_t is defined in <machine/_types.h>.
402 It is an opaque aligned 128-byte struct, of which at most the first
403 12 bytes are used.
404 For more details, see the __mbsinit implementations in
405 Libc-<version>/locale/FreeBSD/
406 {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8,utf2}.c. */
407 /* File INIT_SIZE ZERO_SIZE
408 ascii.c 0 0
409 none.c 0 0
410 euc.c 12 12
411 mskanji.c 4 4
412 big5.c 4 4
413 gb2312.c 4 6
414 gbk.c 4 4
415 gb18030.c 4 8
416 utf8.c 8 10
417 utf2.c 8 12 */
418 # define _GL_MBSTATE_INIT_SIZE 12
419 # define _GL_MBSTATE_ZERO_SIZE 12
420 # elif defined __FreeBSD__ /* FreeBSD */
421 /* On FreeBSD, mbstate_t is defined in src/sys/sys/_types.h.
422 It is an opaque aligned 128-byte struct, of which at most the first
423 12 bytes are used.
424 For more details, see the __mbsinit implementations in
425 src/lib/libc/locale/
426 {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
427 /* File INIT_SIZE ZERO_SIZE
428 ascii.c 0 0
429 none.c 0 0
430 euc.c 12 12
431 mskanji.c 4 4
432 big5.c 4 4
433 gb2312.c 4 6
434 gbk.c 4 4
435 gb18030.c 4 8
436 utf8.c 8 12 */
437 # define _GL_MBSTATE_INIT_SIZE 12
438 # define _GL_MBSTATE_ZERO_SIZE 12
439 # elif defined __NetBSD__ /* NetBSD */
440 /* On NetBSD, mbstate_t is defined in src/sys/sys/ansi.h.
441 It is an opaque aligned 128-byte struct, of which at most the first
442 28 bytes are used.
443 For more details, see the *State types in
444 src/lib/libc/citrus/modules/citrus_*.c
445 (ignoring citrus_{hz,iso2022,utf7,viqr,zw}.c, since these implement
446 stateful encodings, not usable as locale encodings). */
447 /* File ZERO_SIZE
448 citrus/citrus_none.c 0
449 citrus/modules/citrus_euc.c 8
450 citrus/modules/citrus_euctw.c 8
451 citrus/modules/citrus_mskanji.c 8
452 citrus/modules/citrus_big5.c 8
453 citrus/modules/citrus_gbk2k.c 8
454 citrus/modules/citrus_dechanyu.c 8
455 citrus/modules/citrus_johab.c 6
456 citrus/modules/citrus_utf8.c 12 */
457 /* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
458 failures for values < 28. */
459 # define _GL_MBSTATE_ZERO_SIZE 28
460 # elif defined __OpenBSD__ /* OpenBSD */
461 /* On OpenBSD, mbstate_t is defined in src/sys/sys/_types.h.
462 It is an opaque aligned 128-byte struct, of which at most the first
463 12 bytes are used.
464 For more details, see src/lib/libc/citrus/citrus_*.c. */
465 /* File INIT_SIZE ZERO_SIZE
466 citrus_none.c 0 0
467 citrus_utf8.c 12 12 */
468 # define _GL_MBSTATE_INIT_SIZE 12
469 # define _GL_MBSTATE_ZERO_SIZE 12
470 # elif defined __minix /* Minix */
471 /* On Minix, mbstate_t is defined in sys/sys/ansi.h.
472 It is an opaque aligned 128-byte struct.
473 For more details, see the *State types in
474 lib/libc/citrus/citrus_*.c. */
475 /* File INIT_SIZE ZERO_SIZE
476 citrus_none.c 0 0 */
477 /* But 1 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
478 failures for values < 4. */
479 # define _GL_MBSTATE_ZERO_SIZE 4
480 # elif defined __sun /* Solaris */
481 /* On Solaris, mbstate_t is defined in <wchar_impl.h>.
482 It is an opaque aligned 24-byte or 32-byte struct, of which at most the first
483 20 or 28 bytes are used.
484 For more details on OpenSolaris derivatives, see the *State types in
485 illumos-gate/usr/src/lib/libc/port/locale/
486 {none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
487 /* File INIT_SIZE ZERO_SIZE
488 none.c 0 0
489 euc.c 12 12
490 mskanji.c 4 4
491 big5.c 4 4
492 gb2312.c 4 6
493 gbk.c 4 4
494 gb18030.c 4 8
495 utf8.c 12 12 */
496 /* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
497 failures
498 - in OpenIndiana and OmniOS: for values < 16,
499 - in Solaris 10 and 11: for values < 20 (in 32-bit mode)
500 or < 28 (in 64-bit mode).
501 Since we don't have a good way to distinguish the OpenSolaris derivatives
502 from the proprietary Solaris versions, and can't inspect the Solaris source
503 code, use the safe fallback values, below. */
504 # elif defined __CYGWIN__ /* Cygwin */
505 /* On Cygwin, mbstate_t is defined in <sys/_types.h>.
506 For more details, see newlib/libc/stdlib/mbtowc_r.c and
507 winsup/cygwin/strfuncs.cc. */
508 # define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (int) */
509 # define _GL_MBSTATE_ZERO_SIZE 8
510 # elif defined _WIN32 && !defined __CYGWIN__ /* Native Windows. */
511 /* MSVC defines 'mbstate_t' as an aligned 8-byte struct.
512 On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined
513 as an aligned 8-byte struct, of which the first 4 bytes matter.
514 Use the safe values, below. */
515 # elif defined __ANDROID__ /* Android */
516 /* Android defines 'mbstate_t' in <bits/mbstate_t.h>.
517 It is an opaque 4-byte or 8-byte struct.
518 For more details, see
519 bionic/libc/private/bionic_mbstate.h
520 bionic/libc/bionic/mbrtoc32.cpp
521 bionic/libc/bionic/mbrtoc16.cpp
523 # define _GL_MBSTATE_INIT_SIZE 4
524 # define _GL_MBSTATE_ZERO_SIZE 4
525 # endif
526 /* Use safe values as defaults. */
527 # ifndef _GL_MBSTATE_INIT_SIZE
528 # define _GL_MBSTATE_INIT_SIZE sizeof (mbstate_t)
529 # endif
530 # ifndef _GL_MBSTATE_ZERO_SIZE
531 # define _GL_MBSTATE_ZERO_SIZE sizeof (mbstate_t)
532 # endif
533 _GL_BEGIN_C_LINKAGE
534 # if defined IN_MBSZERO
535 _GL_EXTERN_INLINE
536 # else
537 _GL_INLINE
538 # endif
539 _GL_ARG_NONNULL ((1)) void
540 mbszero (mbstate_t *ps)
542 memset (ps, 0, _GL_MBSTATE_ZERO_SIZE);
544 _GL_END_C_LINKAGE
545 _GL_CXXALIAS_SYS (mbszero, void, (mbstate_t *ps));
546 _GL_CXXALIASWARN (mbszero);
547 #endif
550 /* Convert a multibyte character to a wide character. */
551 #if @GNULIB_MBRTOWC@
552 # if @REPLACE_MBRTOWC@
553 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
554 # undef mbrtowc
555 # define mbrtowc rpl_mbrtowc
556 # endif
557 _GL_FUNCDECL_RPL (mbrtowc, size_t,
558 (wchar_t *restrict pwc, const char *restrict s, size_t n,
559 mbstate_t *restrict ps), );
560 _GL_CXXALIAS_RPL (mbrtowc, size_t,
561 (wchar_t *restrict pwc, const char *restrict s, size_t n,
562 mbstate_t *restrict ps));
563 # else
564 # if !@HAVE_MBRTOWC@
565 _GL_FUNCDECL_SYS (mbrtowc, size_t,
566 (wchar_t *restrict pwc, const char *restrict s, size_t n,
567 mbstate_t *restrict ps), );
568 # endif
569 _GL_CXXALIAS_SYS (mbrtowc, size_t,
570 (wchar_t *restrict pwc, const char *restrict s, size_t n,
571 mbstate_t *restrict ps));
572 # endif
573 # if __GLIBC__ >= 2
574 _GL_CXXALIASWARN (mbrtowc);
575 # endif
576 #elif defined GNULIB_POSIXCHECK
577 # undef mbrtowc
578 # if HAVE_RAW_DECL_MBRTOWC
579 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
580 "use gnulib module mbrtowc for portability");
581 # endif
582 #endif
585 /* Recognize a multibyte character. */
586 #if @GNULIB_MBRLEN@
587 # if @REPLACE_MBRLEN@
588 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
589 # undef mbrlen
590 # define mbrlen rpl_mbrlen
591 # endif
592 _GL_FUNCDECL_RPL (mbrlen, size_t,
593 (const char *restrict s, size_t n, mbstate_t *restrict ps), );
594 _GL_CXXALIAS_RPL (mbrlen, size_t,
595 (const char *restrict s, size_t n, mbstate_t *restrict ps));
596 # else
597 # if !@HAVE_MBRLEN@
598 _GL_FUNCDECL_SYS (mbrlen, size_t,
599 (const char *restrict s, size_t n, mbstate_t *restrict ps), );
600 # endif
601 _GL_CXXALIAS_SYS (mbrlen, size_t,
602 (const char *restrict s, size_t n, mbstate_t *restrict ps));
603 # endif
604 # if __GLIBC__ >= 2
605 _GL_CXXALIASWARN (mbrlen);
606 # endif
607 #elif defined GNULIB_POSIXCHECK
608 # undef mbrlen
609 # if HAVE_RAW_DECL_MBRLEN
610 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
611 "use gnulib module mbrlen for portability");
612 # endif
613 #endif
616 /* Convert a string to a wide string. */
617 #if @GNULIB_MBSRTOWCS@
618 # if @REPLACE_MBSRTOWCS@
619 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
620 # undef mbsrtowcs
621 # define mbsrtowcs rpl_mbsrtowcs
622 # endif
623 _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
624 (wchar_t *restrict dest,
625 const char **restrict srcp, size_t len,
626 mbstate_t *restrict ps),
627 _GL_ARG_NONNULL ((2)));
628 _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
629 (wchar_t *restrict dest,
630 const char **restrict srcp, size_t len,
631 mbstate_t *restrict ps));
632 # else
633 # if !@HAVE_MBSRTOWCS@
634 _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
635 (wchar_t *restrict dest,
636 const char **restrict srcp, size_t len,
637 mbstate_t *restrict ps),
638 _GL_ARG_NONNULL ((2)));
639 # endif
640 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
641 (wchar_t *restrict dest,
642 const char **restrict srcp, size_t len,
643 mbstate_t *restrict ps));
644 # endif
645 # if __GLIBC__ >= 2
646 _GL_CXXALIASWARN (mbsrtowcs);
647 # endif
648 #elif defined GNULIB_POSIXCHECK
649 # undef mbsrtowcs
650 # if HAVE_RAW_DECL_MBSRTOWCS
651 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
652 "use gnulib module mbsrtowcs for portability");
653 # endif
654 #endif
657 /* Convert a string to a wide string. */
658 #if @GNULIB_MBSNRTOWCS@
659 # if @REPLACE_MBSNRTOWCS@
660 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
661 # undef mbsnrtowcs
662 # define mbsnrtowcs rpl_mbsnrtowcs
663 # endif
664 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
665 (wchar_t *restrict dest,
666 const char **restrict srcp, size_t srclen, size_t len,
667 mbstate_t *restrict ps),
668 _GL_ARG_NONNULL ((2)));
669 _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
670 (wchar_t *restrict dest,
671 const char **restrict srcp, size_t srclen, size_t len,
672 mbstate_t *restrict ps));
673 # else
674 # if !@HAVE_MBSNRTOWCS@
675 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
676 (wchar_t *restrict dest,
677 const char **restrict srcp, size_t srclen, size_t len,
678 mbstate_t *restrict ps),
679 _GL_ARG_NONNULL ((2)));
680 # endif
681 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
682 (wchar_t *restrict dest,
683 const char **restrict srcp, size_t srclen, size_t len,
684 mbstate_t *restrict ps));
685 # endif
686 # if __GLIBC__ >= 2
687 _GL_CXXALIASWARN (mbsnrtowcs);
688 # endif
689 #elif defined GNULIB_POSIXCHECK
690 # undef mbsnrtowcs
691 # if HAVE_RAW_DECL_MBSNRTOWCS
692 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
693 "use gnulib module mbsnrtowcs for portability");
694 # endif
695 #endif
698 /* Convert a wide character to a multibyte character. */
699 #if @GNULIB_WCRTOMB@
700 # if @REPLACE_WCRTOMB@
701 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
702 # undef wcrtomb
703 # define wcrtomb rpl_wcrtomb
704 # endif
705 _GL_FUNCDECL_RPL (wcrtomb, size_t,
706 (char *restrict s, wchar_t wc, mbstate_t *restrict ps), );
707 _GL_CXXALIAS_RPL (wcrtomb, size_t,
708 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
709 # else
710 # if !@HAVE_WCRTOMB@
711 _GL_FUNCDECL_SYS (wcrtomb, size_t,
712 (char *restrict s, wchar_t wc, mbstate_t *restrict ps), );
713 # endif
714 _GL_CXXALIAS_SYS (wcrtomb, size_t,
715 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
716 # endif
717 # if __GLIBC__ >= 2
718 _GL_CXXALIASWARN (wcrtomb);
719 # endif
720 #elif defined GNULIB_POSIXCHECK
721 # undef wcrtomb
722 # if HAVE_RAW_DECL_WCRTOMB
723 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
724 "use gnulib module wcrtomb for portability");
725 # endif
726 #endif
729 /* Convert a wide string to a string. */
730 #if @GNULIB_WCSRTOMBS@
731 # if @REPLACE_WCSRTOMBS@
732 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
733 # undef wcsrtombs
734 # define wcsrtombs rpl_wcsrtombs
735 # endif
736 _GL_FUNCDECL_RPL (wcsrtombs, size_t,
737 (char *restrict dest, const wchar_t **restrict srcp,
738 size_t len,
739 mbstate_t *restrict ps),
740 _GL_ARG_NONNULL ((2)));
741 _GL_CXXALIAS_RPL (wcsrtombs, size_t,
742 (char *restrict dest, const wchar_t **restrict srcp,
743 size_t len,
744 mbstate_t *restrict ps));
745 # else
746 # if !@HAVE_WCSRTOMBS@
747 _GL_FUNCDECL_SYS (wcsrtombs, size_t,
748 (char *restrict dest, const wchar_t **restrict srcp,
749 size_t len,
750 mbstate_t *restrict ps),
751 _GL_ARG_NONNULL ((2)));
752 # endif
753 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
754 (char *restrict dest, const wchar_t **restrict srcp,
755 size_t len,
756 mbstate_t *restrict ps));
757 # endif
758 # if __GLIBC__ >= 2
759 _GL_CXXALIASWARN (wcsrtombs);
760 # endif
761 #elif defined GNULIB_POSIXCHECK
762 # undef wcsrtombs
763 # if HAVE_RAW_DECL_WCSRTOMBS
764 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
765 "use gnulib module wcsrtombs for portability");
766 # endif
767 #endif
770 /* Convert a wide string to a string. */
771 #if @GNULIB_WCSNRTOMBS@
772 # if @REPLACE_WCSNRTOMBS@
773 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
774 # undef wcsnrtombs
775 # define wcsnrtombs rpl_wcsnrtombs
776 # endif
777 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
778 (char *restrict dest,
779 const wchar_t **restrict srcp, size_t srclen,
780 size_t len,
781 mbstate_t *restrict ps),
782 _GL_ARG_NONNULL ((2)));
783 _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
784 (char *restrict dest,
785 const wchar_t **restrict srcp, size_t srclen,
786 size_t len,
787 mbstate_t *restrict ps));
788 # else
789 # if !@HAVE_WCSNRTOMBS@ || (defined __cplusplus && defined __sun)
790 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
791 (char *restrict dest,
792 const wchar_t **restrict srcp, size_t srclen,
793 size_t len,
794 mbstate_t *restrict ps),
795 _GL_ARG_NONNULL ((2)));
796 # endif
797 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
798 (char *restrict dest,
799 const wchar_t **restrict srcp, size_t srclen,
800 size_t len,
801 mbstate_t *restrict ps));
802 # endif
803 # if __GLIBC__ >= 2
804 _GL_CXXALIASWARN (wcsnrtombs);
805 # endif
806 #elif defined GNULIB_POSIXCHECK
807 # undef wcsnrtombs
808 # if HAVE_RAW_DECL_WCSNRTOMBS
809 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
810 "use gnulib module wcsnrtombs for portability");
811 # endif
812 #endif
815 /* Return the number of screen columns needed for WC. */
816 #if @GNULIB_WCWIDTH@
817 # if @REPLACE_WCWIDTH@
818 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
819 # undef wcwidth
820 # define wcwidth rpl_wcwidth
821 # endif
822 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t), _GL_ATTRIBUTE_PURE);
823 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
824 # else
825 # if !@HAVE_DECL_WCWIDTH@
826 /* wcwidth exists but is not declared. */
827 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t), _GL_ATTRIBUTE_PURE);
828 # endif
829 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
830 # endif
831 # if __GLIBC__ >= 2
832 _GL_CXXALIASWARN (wcwidth);
833 # endif
834 #elif defined GNULIB_POSIXCHECK
835 # undef wcwidth
836 # if HAVE_RAW_DECL_WCWIDTH
837 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
838 "use gnulib module wcwidth for portability");
839 # endif
840 #endif
843 /* Search N wide characters of S for C. */
844 #if @GNULIB_WMEMCHR@
845 # if !@HAVE_WMEMCHR@
846 _GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n),
847 _GL_ATTRIBUTE_PURE);
848 # endif
849 /* On some systems, this function is defined as an overloaded function:
850 extern "C++" {
851 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
852 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
853 } */
854 _GL_CXXALIAS_SYS_CAST2 (wmemchr,
855 wchar_t *, (const wchar_t *, wchar_t, size_t),
856 const wchar_t *, (const wchar_t *, wchar_t, size_t));
857 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
858 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
859 && !defined __clang__
860 _GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
861 _GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
862 (const wchar_t *s, wchar_t c, size_t n));
863 # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
864 _GL_CXXALIASWARN (wmemchr);
865 # endif
866 #elif defined GNULIB_POSIXCHECK
867 # undef wmemchr
868 # if HAVE_RAW_DECL_WMEMCHR
869 _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
870 "use gnulib module wmemchr for portability");
871 # endif
872 #endif
875 /* Compare N wide characters of S1 and S2. */
876 #if @GNULIB_WMEMCMP@
877 # if @REPLACE_WMEMCMP@
878 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
879 # undef wmemcmp
880 # define wmemcmp rpl_wmemcmp
881 # endif
882 _GL_FUNCDECL_RPL (wmemcmp, int,
883 (const wchar_t *s1, const wchar_t *s2, size_t n),
884 _GL_ATTRIBUTE_PURE);
885 _GL_CXXALIAS_RPL (wmemcmp, int,
886 (const wchar_t *s1, const wchar_t *s2, size_t n));
887 # else
888 # if !@HAVE_WMEMCMP@
889 _GL_FUNCDECL_SYS (wmemcmp, int,
890 (const wchar_t *s1, const wchar_t *s2, size_t n),
891 _GL_ATTRIBUTE_PURE);
892 # endif
893 _GL_CXXALIAS_SYS (wmemcmp, int,
894 (const wchar_t *s1, const wchar_t *s2, size_t n));
895 # endif
896 # if __GLIBC__ >= 2
897 _GL_CXXALIASWARN (wmemcmp);
898 # endif
899 #elif defined GNULIB_POSIXCHECK
900 # undef wmemcmp
901 # if HAVE_RAW_DECL_WMEMCMP
902 _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
903 "use gnulib module wmemcmp for portability");
904 # endif
905 #endif
908 /* Copy N wide characters of SRC to DEST. */
909 #if @GNULIB_WMEMCPY@
910 # if !@HAVE_WMEMCPY@
911 _GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
912 (wchar_t *restrict dest,
913 const wchar_t *restrict src, size_t n), );
914 # endif
915 _GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
916 (wchar_t *restrict dest,
917 const wchar_t *restrict src, size_t n));
918 # if __GLIBC__ >= 2
919 _GL_CXXALIASWARN (wmemcpy);
920 # endif
921 #elif defined GNULIB_POSIXCHECK
922 # undef wmemcpy
923 # if HAVE_RAW_DECL_WMEMCPY
924 _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
925 "use gnulib module wmemcpy for portability");
926 # endif
927 #endif
930 /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
931 overlapping memory areas. */
932 #if @GNULIB_WMEMMOVE@
933 # if !@HAVE_WMEMMOVE@
934 _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
935 (wchar_t *dest, const wchar_t *src, size_t n), );
936 # endif
937 _GL_CXXALIAS_SYS (wmemmove, wchar_t *,
938 (wchar_t *dest, const wchar_t *src, size_t n));
939 # if __GLIBC__ >= 2
940 _GL_CXXALIASWARN (wmemmove);
941 # endif
942 #elif defined GNULIB_POSIXCHECK
943 # undef wmemmove
944 # if HAVE_RAW_DECL_WMEMMOVE
945 _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
946 "use gnulib module wmemmove for portability");
947 # endif
948 #endif
951 /* Copy N wide characters of SRC to DEST.
952 Return pointer to wide characters after the last written wide character. */
953 #if @GNULIB_WMEMPCPY@
954 # if @REPLACE_WMEMPCPY@
955 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
956 # undef wmempcpy
957 # define wmempcpy rpl_wmempcpy
958 # endif
959 _GL_FUNCDECL_RPL (wmempcpy, wchar_t *,
960 (wchar_t *restrict dest,
961 const wchar_t *restrict src, size_t n), );
962 _GL_CXXALIAS_RPL (wmempcpy, wchar_t *,
963 (wchar_t *restrict dest,
964 const wchar_t *restrict src, size_t n));
965 # else
966 # if !@HAVE_WMEMPCPY@
967 _GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
968 (wchar_t *restrict dest,
969 const wchar_t *restrict src, size_t n), );
970 # endif
971 _GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
972 (wchar_t *restrict dest,
973 const wchar_t *restrict src, size_t n));
974 # endif
975 # if __GLIBC__ >= 2
976 _GL_CXXALIASWARN (wmempcpy);
977 # endif
978 #elif defined GNULIB_POSIXCHECK
979 # undef wmempcpy
980 # if HAVE_RAW_DECL_WMEMPCPY
981 _GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
982 "use gnulib module wmempcpy for portability");
983 # endif
984 #endif
987 /* Set N wide characters of S to C. */
988 #if @GNULIB_WMEMSET@
989 # if !@HAVE_WMEMSET@
990 _GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n), );
991 # endif
992 _GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
993 # if __GLIBC__ >= 2
994 _GL_CXXALIASWARN (wmemset);
995 # endif
996 #elif defined GNULIB_POSIXCHECK
997 # undef wmemset
998 # if HAVE_RAW_DECL_WMEMSET
999 _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
1000 "use gnulib module wmemset for portability");
1001 # endif
1002 #endif
1005 /* Return the number of wide characters in S. */
1006 #if @GNULIB_WCSLEN@
1007 # if !@HAVE_WCSLEN@
1008 _GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s), _GL_ATTRIBUTE_PURE);
1009 # endif
1010 _GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
1011 # if __GLIBC__ >= 2
1012 _GL_CXXALIASWARN (wcslen);
1013 # endif
1014 #elif defined GNULIB_POSIXCHECK
1015 # undef wcslen
1016 # if HAVE_RAW_DECL_WCSLEN
1017 _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
1018 "use gnulib module wcslen for portability");
1019 # endif
1020 #endif
1023 /* Return the number of wide characters in S, but at most MAXLEN. */
1024 #if @GNULIB_WCSNLEN@
1025 /* On Solaris 11.3, the header files declare the function in the std::
1026 namespace, not in the global namespace. So, force a declaration in
1027 the global namespace. */
1028 # if !@HAVE_WCSNLEN@ || (defined __sun && defined __cplusplus)
1029 _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen),
1030 _GL_ATTRIBUTE_PURE);
1031 # endif
1032 _GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
1033 _GL_CXXALIASWARN (wcsnlen);
1034 #elif defined GNULIB_POSIXCHECK
1035 # undef wcsnlen
1036 # if HAVE_RAW_DECL_WCSNLEN
1037 _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
1038 "use gnulib module wcsnlen for portability");
1039 # endif
1040 #endif
1043 /* Copy SRC to DEST. */
1044 #if @GNULIB_WCSCPY@
1045 # if !@HAVE_WCSCPY@
1046 _GL_FUNCDECL_SYS (wcscpy, wchar_t *,
1047 (wchar_t *restrict dest, const wchar_t *restrict src), );
1048 # endif
1049 _GL_CXXALIAS_SYS (wcscpy, wchar_t *,
1050 (wchar_t *restrict dest, const wchar_t *restrict src));
1051 # if __GLIBC__ >= 2
1052 _GL_CXXALIASWARN (wcscpy);
1053 # endif
1054 #elif defined GNULIB_POSIXCHECK
1055 # undef wcscpy
1056 # if HAVE_RAW_DECL_WCSCPY
1057 _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
1058 "use gnulib module wcscpy for portability");
1059 # endif
1060 #endif
1063 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
1064 #if @GNULIB_WCPCPY@
1065 /* On Solaris 11.3, the header files declare the function in the std::
1066 namespace, not in the global namespace. So, force a declaration in
1067 the global namespace. */
1068 # if !@HAVE_WCPCPY@ || (defined __sun && defined __cplusplus)
1069 _GL_FUNCDECL_SYS (wcpcpy, wchar_t *,
1070 (wchar_t *restrict dest, const wchar_t *restrict src), );
1071 # endif
1072 _GL_CXXALIAS_SYS (wcpcpy, wchar_t *,
1073 (wchar_t *restrict dest, const wchar_t *restrict src));
1074 _GL_CXXALIASWARN (wcpcpy);
1075 #elif defined GNULIB_POSIXCHECK
1076 # undef wcpcpy
1077 # if HAVE_RAW_DECL_WCPCPY
1078 _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
1079 "use gnulib module wcpcpy for portability");
1080 # endif
1081 #endif
1084 /* Copy no more than N wide characters of SRC to DEST. */
1085 #if @GNULIB_WCSNCPY@
1086 # if !@HAVE_WCSNCPY@
1087 _GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
1088 (wchar_t *restrict dest,
1089 const wchar_t *restrict src, size_t n), );
1090 # endif
1091 _GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
1092 (wchar_t *restrict dest,
1093 const wchar_t *restrict src, size_t n));
1094 # if __GLIBC__ >= 2
1095 _GL_CXXALIASWARN (wcsncpy);
1096 # endif
1097 #elif defined GNULIB_POSIXCHECK
1098 # undef wcsncpy
1099 # if HAVE_RAW_DECL_WCSNCPY
1100 _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
1101 "use gnulib module wcsncpy for portability");
1102 # endif
1103 #endif
1106 /* Copy no more than N characters of SRC to DEST, returning the address of
1107 the last character written into DEST. */
1108 #if @GNULIB_WCPNCPY@
1109 /* On Solaris 11.3, the header files declare the function in the std::
1110 namespace, not in the global namespace. So, force a declaration in
1111 the global namespace. */
1112 # if !@HAVE_WCPNCPY@ || (defined __sun && defined __cplusplus)
1113 _GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
1114 (wchar_t *restrict dest,
1115 const wchar_t *restrict src, size_t n), );
1116 # endif
1117 _GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
1118 (wchar_t *restrict dest,
1119 const wchar_t *restrict src, size_t n));
1120 _GL_CXXALIASWARN (wcpncpy);
1121 #elif defined GNULIB_POSIXCHECK
1122 # undef wcpncpy
1123 # if HAVE_RAW_DECL_WCPNCPY
1124 _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
1125 "use gnulib module wcpncpy for portability");
1126 # endif
1127 #endif
1130 /* Append SRC onto DEST. */
1131 #if @GNULIB_WCSCAT@
1132 # if !@HAVE_WCSCAT@
1133 _GL_FUNCDECL_SYS (wcscat, wchar_t *,
1134 (wchar_t *restrict dest, const wchar_t *restrict src), );
1135 # endif
1136 _GL_CXXALIAS_SYS (wcscat, wchar_t *,
1137 (wchar_t *restrict dest, const wchar_t *restrict src));
1138 # if __GLIBC__ >= 2
1139 _GL_CXXALIASWARN (wcscat);
1140 # endif
1141 #elif defined GNULIB_POSIXCHECK
1142 # undef wcscat
1143 # if HAVE_RAW_DECL_WCSCAT
1144 _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
1145 "use gnulib module wcscat for portability");
1146 # endif
1147 #endif
1150 /* Append no more than N wide characters of SRC onto DEST. */
1151 #if @GNULIB_WCSNCAT@
1152 # if @REPLACE_WCSNCAT@
1153 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1154 # undef wcsncat
1155 # define wcsncat rpl_wcsncat
1156 # endif
1157 _GL_FUNCDECL_RPL (wcsncat, wchar_t *,
1158 (wchar_t *restrict dest, const wchar_t *restrict src,
1159 size_t n), );
1160 _GL_CXXALIAS_RPL (wcsncat, wchar_t *,
1161 (wchar_t *restrict dest, const wchar_t *restrict src,
1162 size_t n));
1163 # else
1164 # if !@HAVE_WCSNCAT@
1165 _GL_FUNCDECL_SYS (wcsncat, wchar_t *,
1166 (wchar_t *restrict dest, const wchar_t *restrict src,
1167 size_t n), );
1168 # endif
1169 _GL_CXXALIAS_SYS (wcsncat, wchar_t *,
1170 (wchar_t *restrict dest, const wchar_t *restrict src,
1171 size_t n));
1172 # endif
1173 # if __GLIBC__ >= 2
1174 _GL_CXXALIASWARN (wcsncat);
1175 # endif
1176 #elif defined GNULIB_POSIXCHECK
1177 # undef wcsncat
1178 # if HAVE_RAW_DECL_WCSNCAT
1179 _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
1180 "use gnulib module wcsncat for portability");
1181 # endif
1182 #endif
1185 /* Compare S1 and S2. */
1186 #if @GNULIB_WCSCMP@
1187 # if @REPLACE_WCSCMP@
1188 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1189 # undef wcscmp
1190 # define wcscmp rpl_wcscmp
1191 # endif
1192 _GL_FUNCDECL_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2),
1193 _GL_ATTRIBUTE_PURE);
1194 _GL_CXXALIAS_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
1195 # else
1196 # if !@HAVE_WCSCMP@
1197 _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2),
1198 _GL_ATTRIBUTE_PURE);
1199 # endif
1200 _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
1201 # endif
1202 # if __GLIBC__ >= 2
1203 _GL_CXXALIASWARN (wcscmp);
1204 # endif
1205 #elif defined GNULIB_POSIXCHECK
1206 # undef wcscmp
1207 # if HAVE_RAW_DECL_WCSCMP
1208 _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
1209 "use gnulib module wcscmp for portability");
1210 # endif
1211 #endif
1214 /* Compare no more than N wide characters of S1 and S2. */
1215 #if @GNULIB_WCSNCMP@
1216 # if @REPLACE_WCSNCMP@
1217 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1218 # undef wcsncmp
1219 # define wcsncmp rpl_wcsncmp
1220 # endif
1221 _GL_FUNCDECL_RPL (wcsncmp, int,
1222 (const wchar_t *s1, const wchar_t *s2, size_t n),
1223 _GL_ATTRIBUTE_PURE);
1224 _GL_CXXALIAS_RPL (wcsncmp, int,
1225 (const wchar_t *s1, const wchar_t *s2, size_t n));
1226 # else
1227 # if !@HAVE_WCSNCMP@
1228 _GL_FUNCDECL_SYS (wcsncmp, int,
1229 (const wchar_t *s1, const wchar_t *s2, size_t n),
1230 _GL_ATTRIBUTE_PURE);
1231 # endif
1232 _GL_CXXALIAS_SYS (wcsncmp, int,
1233 (const wchar_t *s1, const wchar_t *s2, size_t n));
1234 # endif
1235 # if __GLIBC__ >= 2
1236 _GL_CXXALIASWARN (wcsncmp);
1237 # endif
1238 #elif defined GNULIB_POSIXCHECK
1239 # undef wcsncmp
1240 # if HAVE_RAW_DECL_WCSNCMP
1241 _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
1242 "use gnulib module wcsncmp for portability");
1243 # endif
1244 #endif
1247 /* Compare S1 and S2, ignoring case. */
1248 #if @GNULIB_WCSCASECMP@
1249 /* On Solaris 11.3, the header files declare the function in the std::
1250 namespace, not in the global namespace. So, force a declaration in
1251 the global namespace. */
1252 # if !@HAVE_WCSCASECMP@ || (defined __sun && defined __cplusplus)
1253 _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2),
1254 _GL_ATTRIBUTE_PURE);
1255 # endif
1256 _GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
1257 _GL_CXXALIASWARN (wcscasecmp);
1258 #elif defined GNULIB_POSIXCHECK
1259 # undef wcscasecmp
1260 # if HAVE_RAW_DECL_WCSCASECMP
1261 _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
1262 "use gnulib module wcscasecmp for portability");
1263 # endif
1264 #endif
1267 /* Compare no more than N chars of S1 and S2, ignoring case. */
1268 #if @GNULIB_WCSNCASECMP@
1269 /* On Solaris 11.3, the header files declare the function in the std::
1270 namespace, not in the global namespace. So, force a declaration in
1271 the global namespace. */
1272 # if !@HAVE_WCSNCASECMP@ || (defined __sun && defined __cplusplus)
1273 _GL_FUNCDECL_SYS (wcsncasecmp, int,
1274 (const wchar_t *s1, const wchar_t *s2, size_t n),
1275 _GL_ATTRIBUTE_PURE);
1276 # endif
1277 _GL_CXXALIAS_SYS (wcsncasecmp, int,
1278 (const wchar_t *s1, const wchar_t *s2, size_t n));
1279 _GL_CXXALIASWARN (wcsncasecmp);
1280 #elif defined GNULIB_POSIXCHECK
1281 # undef wcsncasecmp
1282 # if HAVE_RAW_DECL_WCSNCASECMP
1283 _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
1284 "use gnulib module wcsncasecmp for portability");
1285 # endif
1286 #endif
1289 /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
1290 category of the current locale. */
1291 #if @GNULIB_WCSCOLL@
1292 # if !@HAVE_WCSCOLL@
1293 _GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2), );
1294 # endif
1295 _GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
1296 # if __GLIBC__ >= 2
1297 _GL_CXXALIASWARN (wcscoll);
1298 # endif
1299 #elif defined GNULIB_POSIXCHECK
1300 # undef wcscoll
1301 # if HAVE_RAW_DECL_WCSCOLL
1302 _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
1303 "use gnulib module wcscoll for portability");
1304 # endif
1305 #endif
1308 /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
1309 to two transformed strings the result is the as applying 'wcscoll' to the
1310 original strings. */
1311 #if @GNULIB_WCSXFRM@
1312 # if !@HAVE_WCSXFRM@
1313 _GL_FUNCDECL_SYS (wcsxfrm, size_t,
1314 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n), );
1315 # endif
1316 _GL_CXXALIAS_SYS (wcsxfrm, size_t,
1317 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
1318 # if __GLIBC__ >= 2
1319 _GL_CXXALIASWARN (wcsxfrm);
1320 # endif
1321 #elif defined GNULIB_POSIXCHECK
1322 # undef wcsxfrm
1323 # if HAVE_RAW_DECL_WCSXFRM
1324 _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
1325 "use gnulib module wcsxfrm for portability");
1326 # endif
1327 #endif
1330 /* Duplicate S, returning an identical malloc'd string. */
1331 #if @GNULIB_WCSDUP@
1332 # if defined _WIN32 && !defined __CYGWIN__
1333 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1334 # undef wcsdup
1335 # define wcsdup _wcsdup
1336 # endif
1337 _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1338 # else
1339 /* On Solaris 11.3, the header files declare the function in the std::
1340 namespace, not in the global namespace. So, force a declaration in
1341 the global namespace. */
1342 # if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) \
1343 || (__GNUC__ >= 11 && !defined __clang__)
1344 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1345 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1346 (const wchar_t *s),
1347 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1348 _GL_ATTRIBUTE_NOTHROW;
1349 # else
1350 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1351 (const wchar_t *s),
1352 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1353 # endif
1354 # endif
1355 _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1356 # endif
1357 _GL_CXXALIASWARN (wcsdup);
1358 #else
1359 # if (__GNUC__ >= 11 && !defined __clang__) && !defined wcsdup
1360 /* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */
1361 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1362 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1363 (const wchar_t *s),
1364 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1365 _GL_ATTRIBUTE_NOTHROW;
1366 # else
1367 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1368 (const wchar_t *s),
1369 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1370 # endif
1371 # endif
1372 # if defined GNULIB_POSIXCHECK
1373 # undef wcsdup
1374 # if HAVE_RAW_DECL_WCSDUP
1375 _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
1376 "use gnulib module wcsdup for portability");
1377 # endif
1378 # elif @GNULIB_MDA_WCSDUP@
1379 /* On native Windows, map 'wcsdup' to '_wcsdup', so that -loldnames is not
1380 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1381 platforms by defining GNULIB_NAMESPACE::wcsdup always. */
1382 # if defined _WIN32 && !defined __CYGWIN__
1383 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1384 # undef wcsdup
1385 # define wcsdup _wcsdup
1386 # endif
1387 _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1388 # else
1389 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1390 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1391 (const wchar_t *s),
1392 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1393 _GL_ATTRIBUTE_NOTHROW;
1394 # else
1395 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1396 (const wchar_t *s),
1397 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1398 # endif
1399 # if @HAVE_DECL_WCSDUP@
1400 _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1401 # endif
1402 # endif
1403 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_WCSDUP@
1404 _GL_CXXALIASWARN (wcsdup);
1405 # endif
1406 # endif
1407 #endif
1410 /* Find the first occurrence of WC in WCS. */
1411 #if @GNULIB_WCSCHR@
1412 # if !@HAVE_WCSCHR@
1413 _GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc),
1414 _GL_ATTRIBUTE_PURE);
1415 # endif
1416 /* On some systems, this function is defined as an overloaded function:
1417 extern "C++" {
1418 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
1419 wchar_t * std::wcschr (wchar_t *, wchar_t);
1420 } */
1421 _GL_CXXALIAS_SYS_CAST2 (wcschr,
1422 wchar_t *, (const wchar_t *, wchar_t),
1423 const wchar_t *, (const wchar_t *, wchar_t));
1424 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1425 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1426 && !defined __clang__
1427 _GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
1428 _GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
1429 # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1430 _GL_CXXALIASWARN (wcschr);
1431 # endif
1432 #elif defined GNULIB_POSIXCHECK
1433 # undef wcschr
1434 # if HAVE_RAW_DECL_WCSCHR
1435 _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
1436 "use gnulib module wcschr for portability");
1437 # endif
1438 #endif
1441 /* Find the last occurrence of WC in WCS. */
1442 #if @GNULIB_WCSRCHR@
1443 # if !@HAVE_WCSRCHR@
1444 _GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc),
1445 _GL_ATTRIBUTE_PURE);
1446 # endif
1447 /* On some systems, this function is defined as an overloaded function:
1448 extern "C++" {
1449 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
1450 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
1451 } */
1452 _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
1453 wchar_t *, (const wchar_t *, wchar_t),
1454 const wchar_t *, (const wchar_t *, wchar_t));
1455 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1456 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1457 && !defined __clang__
1458 _GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
1459 _GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
1460 # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1461 _GL_CXXALIASWARN (wcsrchr);
1462 # endif
1463 #elif defined GNULIB_POSIXCHECK
1464 # undef wcsrchr
1465 # if HAVE_RAW_DECL_WCSRCHR
1466 _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
1467 "use gnulib module wcsrchr for portability");
1468 # endif
1469 #endif
1472 /* Return the length of the initial segment of WCS which consists entirely
1473 of wide characters not in REJECT. */
1474 #if @GNULIB_WCSCSPN@
1475 # if !@HAVE_WCSCSPN@
1476 _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject),
1477 _GL_ATTRIBUTE_PURE);
1478 # endif
1479 _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
1480 # if __GLIBC__ >= 2
1481 _GL_CXXALIASWARN (wcscspn);
1482 # endif
1483 #elif defined GNULIB_POSIXCHECK
1484 # undef wcscspn
1485 # if HAVE_RAW_DECL_WCSCSPN
1486 _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
1487 "use gnulib module wcscspn for portability");
1488 # endif
1489 #endif
1492 /* Return the length of the initial segment of WCS which consists entirely
1493 of wide characters in ACCEPT. */
1494 #if @GNULIB_WCSSPN@
1495 # if !@HAVE_WCSSPN@
1496 _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept),
1497 _GL_ATTRIBUTE_PURE);
1498 # endif
1499 _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
1500 # if __GLIBC__ >= 2
1501 _GL_CXXALIASWARN (wcsspn);
1502 # endif
1503 #elif defined GNULIB_POSIXCHECK
1504 # undef wcsspn
1505 # if HAVE_RAW_DECL_WCSSPN
1506 _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
1507 "use gnulib module wcsspn for portability");
1508 # endif
1509 #endif
1512 /* Find the first occurrence in WCS of any character in ACCEPT. */
1513 #if @GNULIB_WCSPBRK@
1514 # if !@HAVE_WCSPBRK@
1515 _GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
1516 (const wchar_t *wcs, const wchar_t *accept),
1517 _GL_ATTRIBUTE_PURE);
1518 # endif
1519 /* On some systems, this function is defined as an overloaded function:
1520 extern "C++" {
1521 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
1522 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
1523 } */
1524 _GL_CXXALIAS_SYS_CAST2 (wcspbrk,
1525 wchar_t *, (const wchar_t *, const wchar_t *),
1526 const wchar_t *, (const wchar_t *, const wchar_t *));
1527 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1528 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1529 && !defined __clang__
1530 _GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
1531 (wchar_t *wcs, const wchar_t *accept));
1532 _GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
1533 (const wchar_t *wcs, const wchar_t *accept));
1534 # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1535 _GL_CXXALIASWARN (wcspbrk);
1536 # endif
1537 #elif defined GNULIB_POSIXCHECK
1538 # undef wcspbrk
1539 # if HAVE_RAW_DECL_WCSPBRK
1540 _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
1541 "use gnulib module wcspbrk for portability");
1542 # endif
1543 #endif
1546 /* Find the first occurrence of NEEDLE in HAYSTACK. */
1547 #if @GNULIB_WCSSTR@
1548 # if @REPLACE_WCSSTR@
1549 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1550 # undef wcsstr
1551 # define wcsstr rpl_wcsstr
1552 # endif
1553 _GL_FUNCDECL_RPL (wcsstr, wchar_t *,
1554 (const wchar_t *restrict haystack,
1555 const wchar_t *restrict needle),
1556 _GL_ATTRIBUTE_PURE);
1557 _GL_CXXALIAS_RPL (wcsstr, wchar_t *,
1558 (const wchar_t *restrict haystack,
1559 const wchar_t *restrict needle));
1560 # else
1561 # if !@HAVE_WCSSTR@
1562 _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
1563 (const wchar_t *restrict haystack,
1564 const wchar_t *restrict needle),
1565 _GL_ATTRIBUTE_PURE);
1566 # endif
1567 /* On some systems, this function is defined as an overloaded function:
1568 extern "C++" {
1569 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
1570 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
1571 } */
1572 _GL_CXXALIAS_SYS_CAST2 (wcsstr,
1573 wchar_t *,
1574 (const wchar_t *restrict, const wchar_t *restrict),
1575 const wchar_t *,
1576 (const wchar_t *restrict, const wchar_t *restrict));
1577 # endif
1578 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1579 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1580 && !defined __clang__
1581 _GL_CXXALIASWARN1 (wcsstr, wchar_t *,
1582 (wchar_t *restrict haystack,
1583 const wchar_t *restrict needle));
1584 _GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
1585 (const wchar_t *restrict haystack,
1586 const wchar_t *restrict needle));
1587 # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1588 _GL_CXXALIASWARN (wcsstr);
1589 # endif
1590 #elif defined GNULIB_POSIXCHECK
1591 # undef wcsstr
1592 # if HAVE_RAW_DECL_WCSSTR
1593 _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
1594 "use gnulib module wcsstr for portability");
1595 # endif
1596 #endif
1599 /* Divide WCS into tokens separated by characters in DELIM. */
1600 #if @GNULIB_WCSTOK@
1601 # if @REPLACE_WCSTOK@
1602 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1603 # undef wcstok
1604 # define wcstok rpl_wcstok
1605 # endif
1606 _GL_FUNCDECL_RPL (wcstok, wchar_t *,
1607 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1608 wchar_t **restrict ptr), );
1609 _GL_CXXALIAS_RPL (wcstok, wchar_t *,
1610 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1611 wchar_t **restrict ptr));
1612 # else
1613 # if !@HAVE_WCSTOK@
1614 _GL_FUNCDECL_SYS (wcstok, wchar_t *,
1615 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1616 wchar_t **restrict ptr), );
1617 # endif
1618 _GL_CXXALIAS_SYS (wcstok, wchar_t *,
1619 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1620 wchar_t **restrict ptr));
1621 # endif
1622 # if __GLIBC__ >= 2
1623 _GL_CXXALIASWARN (wcstok);
1624 # endif
1625 #elif defined GNULIB_POSIXCHECK
1626 # undef wcstok
1627 # if HAVE_RAW_DECL_WCSTOK
1628 _GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
1629 "use gnulib module wcstok for portability");
1630 # endif
1631 #endif
1634 /* Determine number of column positions required for first N wide
1635 characters (or fewer if S ends before this) in S. */
1636 #if @GNULIB_WCSWIDTH@
1637 # if @REPLACE_WCSWIDTH@
1638 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1639 # undef wcswidth
1640 # define wcswidth rpl_wcswidth
1641 # endif
1642 _GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n),
1643 _GL_ATTRIBUTE_PURE);
1644 _GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
1645 # else
1646 # if !@HAVE_WCSWIDTH@
1647 _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n),
1648 _GL_ATTRIBUTE_PURE);
1649 # endif
1650 _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
1651 # endif
1652 # if __GLIBC__ >= 2
1653 _GL_CXXALIASWARN (wcswidth);
1654 # endif
1655 #elif defined GNULIB_POSIXCHECK
1656 # undef wcswidth
1657 # if HAVE_RAW_DECL_WCSWIDTH
1658 _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1659 "use gnulib module wcswidth for portability");
1660 # endif
1661 #endif
1664 /* Convert *TP to a date and time wide string. See
1665 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
1666 #if @GNULIB_WCSFTIME@
1667 # if @REPLACE_WCSFTIME@
1668 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1669 # undef wcsftime
1670 # define wcsftime rpl_wcsftime
1671 # endif
1672 _GL_FUNCDECL_RPL (wcsftime, size_t,
1673 (wchar_t *restrict __buf, size_t __bufsize,
1674 const wchar_t *restrict __fmt,
1675 const struct tm *restrict __tp),
1676 _GL_ARG_NONNULL ((1, 3, 4)));
1677 _GL_CXXALIAS_RPL (wcsftime, size_t,
1678 (wchar_t *restrict __buf, size_t __bufsize,
1679 const wchar_t *restrict __fmt,
1680 const struct tm *restrict __tp));
1681 # else
1682 # if !@HAVE_WCSFTIME@
1683 _GL_FUNCDECL_SYS (wcsftime, size_t,
1684 (wchar_t *restrict __buf, size_t __bufsize,
1685 const wchar_t *restrict __fmt,
1686 const struct tm *restrict __tp),
1687 _GL_ARG_NONNULL ((1, 3, 4)));
1688 # endif
1689 _GL_CXXALIAS_SYS (wcsftime, size_t,
1690 (wchar_t *restrict __buf, size_t __bufsize,
1691 const wchar_t *restrict __fmt,
1692 const struct tm *restrict __tp));
1693 # endif
1694 # if __GLIBC__ >= 2
1695 _GL_CXXALIASWARN (wcsftime);
1696 # endif
1697 #elif defined GNULIB_POSIXCHECK
1698 # undef wcsftime
1699 # if HAVE_RAW_DECL_WCSFTIME
1700 _GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
1701 "use gnulib module wcsftime for portability");
1702 # endif
1703 #endif
1706 #if @GNULIB_WGETCWD@ && (defined _WIN32 && !defined __CYGWIN__)
1707 /* Gets the name of the current working directory.
1708 (a) If BUF is non-NULL, it is assumed to have room for SIZE wide characters.
1709 This function stores the working directory (NUL-terminated) in BUF and
1710 returns BUF.
1711 (b) If BUF is NULL, an array is allocated with 'malloc'. The array is SIZE
1712 wide characters long, unless SIZE == 0, in which case it is as big as
1713 necessary.
1714 If the directory couldn't be determined or SIZE was too small, this function
1715 returns NULL and sets errno. For a directory of length LEN, SIZE should be
1716 >= LEN + 3 in case (a) or >= LEN + 1 in case (b).
1717 Possible errno values include:
1718 - ERANGE if SIZE is too small.
1719 - ENOMEM if the memory could no be allocated. */
1720 _GL_FUNCDECL_SYS (wgetcwd, wchar_t *, (wchar_t *buf, size_t size), );
1721 #endif
1724 #endif /* _@GUARD_PREFIX@_WCHAR_H */
1725 #endif /* _@GUARD_PREFIX@_WCHAR_H */
1726 #endif