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().
29 @PRAGMA_SYSTEM_HEADER@
33 #if (((defined __need_mbstate_t || defined __need_wint_t) \
34 && !defined __MINGW32__) \
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@
58 /* Normal invocation convention. */
60 #ifndef _@GUARD_PREFIX@_WCHAR_H
62 #define _GL_ALREADY_INCLUDING_WCHAR_H
65 # include <features.h> /* for __GLIBC__ */
68 /* In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
70 But avoid namespace pollution on glibc systems. */
71 #if !(defined __GLIBC__ && !defined __UCLIBC__)
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. */
79 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
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,
90 #if !_GL_CONFIG_H_INCLUDED
91 #error "Please include config.h first."
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
97 #ifndef _GL_ATTRIBUTE_DEALLOC
99 # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
101 # define _GL_ATTRIBUTE_DEALLOC(f, i)
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)
114 # define _GL_ATTRIBUTE_DEALLOC_FREE \
115 _GL_ATTRIBUTE_DEALLOC (free, 1)
119 /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
121 /* Applies to: functions. */
122 #ifndef _GL_ATTRIBUTE_MALLOC
123 # if __GNUC__ >= 3 || defined __clang__
124 # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
126 # define _GL_ATTRIBUTE_MALLOC
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__))
136 # define _GL_ATTRIBUTE_PURE /* empty */
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)
148 # define _GL_ATTRIBUTE_NOTHROW throw ()
151 # define _GL_ATTRIBUTE_NOTHROW
154 # if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
155 # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
157 # define _GL_ATTRIBUTE_NOTHROW
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
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>
186 typedef unsigned int rpl_wint_t
;
188 # define wint_t rpl_wint_t
189 # define GNULIB_defined_wint_t 1
193 # define WEOF ((wint_t) -1)
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
;
208 # define mbstate_t rpl_mbstate_t
210 # define GNULIB_defined_mbstate_t 1
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
;
223 _GL_EXTERN_C
void rpl_free (void *);
225 # undef _GL_ATTRIBUTE_DEALLOC_FREE
226 # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
228 # if defined _MSC_VER && !defined free
231 __declspec (dllimport
)
233 void __cdecl
free (void *);
235 # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
236 _GL_EXTERN_C
void free (void *) _GL_ATTRIBUTE_NOTHROW
;
238 _GL_EXTERN_C
void free (void *);
243 # if defined _MSC_VER && !defined free
246 __declspec (dllimport
)
248 void __cdecl
free (void *);
250 # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
251 _GL_EXTERN_C
void free (void *) _GL_ATTRIBUTE_NOTHROW
;
253 _GL_EXTERN_C
void free (void *);
265 /* Convert a single-byte character to a wide character. */
268 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
270 # define btowc rpl_btowc
272 _GL_FUNCDECL_RPL (btowc
, wint_t, (int c
) _GL_ATTRIBUTE_PURE
);
273 _GL_CXXALIAS_RPL (btowc
, wint_t, (int c
));
276 _GL_FUNCDECL_SYS (btowc
, wint_t, (int c
) _GL_ATTRIBUTE_PURE
);
278 /* Need to cast, because on mingw, the return type is 'unsigned short'. */
279 _GL_CXXALIAS_SYS_CAST (btowc
, wint_t, (int c
));
282 _GL_CXXALIASWARN (btowc
);
284 #elif defined GNULIB_POSIXCHECK
286 # if HAVE_RAW_DECL_BTOWC
287 _GL_WARN_ON_USE (btowc
, "btowc is unportable - "
288 "use gnulib module btowc for portability");
293 /* Convert a wide character to a single-byte character. */
296 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
298 # define wctob rpl_wctob
300 _GL_FUNCDECL_RPL (wctob
, int, (wint_t wc
) _GL_ATTRIBUTE_PURE
);
301 _GL_CXXALIAS_RPL (wctob
, int, (wint_t wc
));
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
);
307 _GL_CXXALIAS_SYS (wctob
, int, (wint_t wc
));
310 _GL_CXXALIASWARN (wctob
);
312 #elif defined GNULIB_POSIXCHECK
314 # if HAVE_RAW_DECL_WCTOB
315 _GL_WARN_ON_USE (wctob
, "wctob is unportable - "
316 "use gnulib module wctob for portability");
321 /* Test whether *PS is in an initial state. */
323 # if @REPLACE_MBSINIT@
324 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
326 # define mbsinit rpl_mbsinit
328 _GL_FUNCDECL_RPL (mbsinit
, int, (const mbstate_t *ps
));
329 _GL_CXXALIAS_RPL (mbsinit
, int, (const mbstate_t *ps
));
332 _GL_FUNCDECL_SYS (mbsinit
, int, (const mbstate_t *ps
));
334 _GL_CXXALIAS_SYS (mbsinit
, int, (const mbstate_t *ps
));
337 _GL_CXXALIASWARN (mbsinit
);
339 #elif defined GNULIB_POSIXCHECK
341 # if HAVE_RAW_DECL_MBSINIT
342 _GL_WARN_ON_USE (mbsinit
, "mbsinit is unportable - "
343 "use gnulib module mbsinit for portability");
348 /* Put *PS into an initial state. */
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 };
360 memset (&state, 0, sizeof (mbstate_t));
362 we can write this faster code:
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()
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
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
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
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
424 For more details, see the __mbsinit implementations in
426 {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
427 /* File INIT_SIZE ZERO_SIZE
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
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). */
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
464 For more details, see src/lib/libc/citrus/citrus_*.c. */
465 /* File INIT_SIZE ZERO_SIZE
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
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
496 /* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
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
526 /* Use safe values as defaults. */
527 # ifndef _GL_MBSTATE_INIT_SIZE
528 # define _GL_MBSTATE_INIT_SIZE sizeof (mbstate_t)
530 # ifndef _GL_MBSTATE_ZERO_SIZE
531 # define _GL_MBSTATE_ZERO_SIZE sizeof (mbstate_t)
534 # if defined IN_MBSZERO
539 _GL_ARG_NONNULL ((1)) void
540 mbszero (mbstate_t *ps
)
542 memset (ps
, 0, _GL_MBSTATE_ZERO_SIZE
);
545 _GL_CXXALIAS_SYS (mbszero
, void, (mbstate_t *ps
));
546 _GL_CXXALIASWARN (mbszero
);
550 /* Convert a multibyte character to a wide character. */
552 # if @REPLACE_MBRTOWC@
553 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
555 # define mbrtowc rpl_mbrtowc
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
));
565 _GL_FUNCDECL_SYS (mbrtowc
, size_t,
566 (wchar_t *restrict pwc
, const char *restrict s
, size_t n
,
567 mbstate_t *restrict ps
));
569 _GL_CXXALIAS_SYS (mbrtowc
, size_t,
570 (wchar_t *restrict pwc
, const char *restrict s
, size_t n
,
571 mbstate_t *restrict ps
));
574 _GL_CXXALIASWARN (mbrtowc
);
576 #elif defined GNULIB_POSIXCHECK
578 # if HAVE_RAW_DECL_MBRTOWC
579 _GL_WARN_ON_USE (mbrtowc
, "mbrtowc is unportable - "
580 "use gnulib module mbrtowc for portability");
585 /* Recognize a multibyte character. */
587 # if @REPLACE_MBRLEN@
588 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
590 # define mbrlen rpl_mbrlen
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
));
598 _GL_FUNCDECL_SYS (mbrlen
, size_t,
599 (const char *restrict s
, size_t n
, mbstate_t *restrict ps
));
601 _GL_CXXALIAS_SYS (mbrlen
, size_t,
602 (const char *restrict s
, size_t n
, mbstate_t *restrict ps
));
605 _GL_CXXALIASWARN (mbrlen
);
607 #elif defined GNULIB_POSIXCHECK
609 # if HAVE_RAW_DECL_MBRLEN
610 _GL_WARN_ON_USE (mbrlen
, "mbrlen is unportable - "
611 "use gnulib module mbrlen for portability");
616 /* Convert a string to a wide string. */
617 #if @GNULIB_MBSRTOWCS@
618 # if @REPLACE_MBSRTOWCS@
619 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
621 # define mbsrtowcs rpl_mbsrtowcs
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
));
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)));
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
));
646 _GL_CXXALIASWARN (mbsrtowcs
);
648 #elif defined GNULIB_POSIXCHECK
650 # if HAVE_RAW_DECL_MBSRTOWCS
651 _GL_WARN_ON_USE (mbsrtowcs
, "mbsrtowcs is unportable - "
652 "use gnulib module mbsrtowcs for portability");
657 /* Convert a string to a wide string. */
658 #if @GNULIB_MBSNRTOWCS@
659 # if @REPLACE_MBSNRTOWCS@
660 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
662 # define mbsnrtowcs rpl_mbsnrtowcs
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
));
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)));
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
));
687 _GL_CXXALIASWARN (mbsnrtowcs
);
689 #elif defined GNULIB_POSIXCHECK
691 # if HAVE_RAW_DECL_MBSNRTOWCS
692 _GL_WARN_ON_USE (mbsnrtowcs
, "mbsnrtowcs is unportable - "
693 "use gnulib module mbsnrtowcs for portability");
698 /* Convert a wide character to a multibyte character. */
700 # if @REPLACE_WCRTOMB@
701 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
703 # define wcrtomb rpl_wcrtomb
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
));
711 _GL_FUNCDECL_SYS (wcrtomb
, size_t,
712 (char *restrict s
, wchar_t wc
, mbstate_t *restrict ps
));
714 _GL_CXXALIAS_SYS (wcrtomb
, size_t,
715 (char *restrict s
, wchar_t wc
, mbstate_t *restrict ps
));
718 _GL_CXXALIASWARN (wcrtomb
);
720 #elif defined GNULIB_POSIXCHECK
722 # if HAVE_RAW_DECL_WCRTOMB
723 _GL_WARN_ON_USE (wcrtomb
, "wcrtomb is unportable - "
724 "use gnulib module wcrtomb for portability");
729 /* Convert a wide string to a string. */
730 #if @GNULIB_WCSRTOMBS@
731 # if @REPLACE_WCSRTOMBS@
732 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
734 # define wcsrtombs rpl_wcsrtombs
736 _GL_FUNCDECL_RPL (wcsrtombs
, size_t,
737 (char *restrict dest
, const wchar_t **restrict srcp
,
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
,
744 mbstate_t *restrict ps
));
746 # if !@HAVE_WCSRTOMBS@
747 _GL_FUNCDECL_SYS (wcsrtombs
, size_t,
748 (char *restrict dest
, const wchar_t **restrict srcp
,
750 mbstate_t *restrict ps
)
751 _GL_ARG_NONNULL ((2)));
753 _GL_CXXALIAS_SYS (wcsrtombs
, size_t,
754 (char *restrict dest
, const wchar_t **restrict srcp
,
756 mbstate_t *restrict ps
));
759 _GL_CXXALIASWARN (wcsrtombs
);
761 #elif defined GNULIB_POSIXCHECK
763 # if HAVE_RAW_DECL_WCSRTOMBS
764 _GL_WARN_ON_USE (wcsrtombs
, "wcsrtombs is unportable - "
765 "use gnulib module wcsrtombs for portability");
770 /* Convert a wide string to a string. */
771 #if @GNULIB_WCSNRTOMBS@
772 # if @REPLACE_WCSNRTOMBS@
773 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
775 # define wcsnrtombs rpl_wcsnrtombs
777 _GL_FUNCDECL_RPL (wcsnrtombs
, size_t,
778 (char *restrict dest
,
779 const wchar_t **restrict srcp
, size_t srclen
,
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
,
787 mbstate_t *restrict ps
));
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
,
794 mbstate_t *restrict ps
)
795 _GL_ARG_NONNULL ((2)));
797 _GL_CXXALIAS_SYS (wcsnrtombs
, size_t,
798 (char *restrict dest
,
799 const wchar_t **restrict srcp
, size_t srclen
,
801 mbstate_t *restrict ps
));
804 _GL_CXXALIASWARN (wcsnrtombs
);
806 #elif defined GNULIB_POSIXCHECK
808 # if HAVE_RAW_DECL_WCSNRTOMBS
809 _GL_WARN_ON_USE (wcsnrtombs
, "wcsnrtombs is unportable - "
810 "use gnulib module wcsnrtombs for portability");
815 /* Return the number of screen columns needed for WC. */
817 # if @REPLACE_WCWIDTH@
818 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
820 # define wcwidth rpl_wcwidth
822 _GL_FUNCDECL_RPL (wcwidth
, int, (wchar_t) _GL_ATTRIBUTE_PURE
);
823 _GL_CXXALIAS_RPL (wcwidth
, int, (wchar_t));
825 # if !@HAVE_DECL_WCWIDTH@
826 /* wcwidth exists but is not declared. */
827 _GL_FUNCDECL_SYS (wcwidth
, int, (wchar_t) _GL_ATTRIBUTE_PURE
);
829 _GL_CXXALIAS_SYS (wcwidth
, int, (wchar_t));
832 _GL_CXXALIASWARN (wcwidth
);
834 #elif defined GNULIB_POSIXCHECK
836 # if HAVE_RAW_DECL_WCWIDTH
837 _GL_WARN_ON_USE (wcwidth
, "wcwidth is unportable - "
838 "use gnulib module wcwidth for portability");
843 /* Search N wide characters of S for C. */
846 _GL_FUNCDECL_SYS (wmemchr
, wchar_t *, (const wchar_t *s
, wchar_t c
, size_t n
)
849 /* On some systems, this function is defined as an overloaded function:
851 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
852 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
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 _GL_CXXALIASWARN1 (wmemchr
, wchar_t *, (wchar_t *s
, wchar_t c
, size_t n
));
860 _GL_CXXALIASWARN1 (wmemchr
, const wchar_t *,
861 (const wchar_t *s
, wchar_t c
, size_t n
));
862 # elif __GLIBC__ >= 2
863 _GL_CXXALIASWARN (wmemchr
);
865 #elif defined GNULIB_POSIXCHECK
867 # if HAVE_RAW_DECL_WMEMCHR
868 _GL_WARN_ON_USE (wmemchr
, "wmemchr is unportable - "
869 "use gnulib module wmemchr for portability");
874 /* Compare N wide characters of S1 and S2. */
876 # if @REPLACE_WMEMCMP@
877 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
879 # define wmemcmp rpl_wmemcmp
881 _GL_FUNCDECL_RPL (wmemcmp
, int,
882 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
884 _GL_CXXALIAS_RPL (wmemcmp
, int,
885 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
888 _GL_FUNCDECL_SYS (wmemcmp
, int,
889 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
892 _GL_CXXALIAS_SYS (wmemcmp
, int,
893 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
896 _GL_CXXALIASWARN (wmemcmp
);
898 #elif defined GNULIB_POSIXCHECK
900 # if HAVE_RAW_DECL_WMEMCMP
901 _GL_WARN_ON_USE (wmemcmp
, "wmemcmp is unportable - "
902 "use gnulib module wmemcmp for portability");
907 /* Copy N wide characters of SRC to DEST. */
910 _GL_FUNCDECL_SYS (wmemcpy
, wchar_t *,
911 (wchar_t *restrict dest
,
912 const wchar_t *restrict src
, size_t n
));
914 _GL_CXXALIAS_SYS (wmemcpy
, wchar_t *,
915 (wchar_t *restrict dest
,
916 const wchar_t *restrict src
, size_t n
));
918 _GL_CXXALIASWARN (wmemcpy
);
920 #elif defined GNULIB_POSIXCHECK
922 # if HAVE_RAW_DECL_WMEMCPY
923 _GL_WARN_ON_USE (wmemcpy
, "wmemcpy is unportable - "
924 "use gnulib module wmemcpy for portability");
929 /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
930 overlapping memory areas. */
931 #if @GNULIB_WMEMMOVE@
932 # if !@HAVE_WMEMMOVE@
933 _GL_FUNCDECL_SYS (wmemmove
, wchar_t *,
934 (wchar_t *dest
, const wchar_t *src
, size_t n
));
936 _GL_CXXALIAS_SYS (wmemmove
, wchar_t *,
937 (wchar_t *dest
, const wchar_t *src
, size_t n
));
939 _GL_CXXALIASWARN (wmemmove
);
941 #elif defined GNULIB_POSIXCHECK
943 # if HAVE_RAW_DECL_WMEMMOVE
944 _GL_WARN_ON_USE (wmemmove
, "wmemmove is unportable - "
945 "use gnulib module wmemmove for portability");
950 /* Copy N wide characters of SRC to DEST.
951 Return pointer to wide characters after the last written wide character. */
952 #if @GNULIB_WMEMPCPY@
953 # if @REPLACE_WMEMPCPY@
954 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
956 # define wmempcpy rpl_wmempcpy
958 _GL_FUNCDECL_RPL (wmempcpy
, wchar_t *,
959 (wchar_t *restrict dest
,
960 const wchar_t *restrict src
, size_t n
));
961 _GL_CXXALIAS_RPL (wmempcpy
, wchar_t *,
962 (wchar_t *restrict dest
,
963 const wchar_t *restrict src
, size_t n
));
965 # if !@HAVE_WMEMPCPY@
966 _GL_FUNCDECL_SYS (wmempcpy
, wchar_t *,
967 (wchar_t *restrict dest
,
968 const wchar_t *restrict src
, size_t n
));
970 _GL_CXXALIAS_SYS (wmempcpy
, wchar_t *,
971 (wchar_t *restrict dest
,
972 const wchar_t *restrict src
, size_t n
));
975 _GL_CXXALIASWARN (wmempcpy
);
977 #elif defined GNULIB_POSIXCHECK
979 # if HAVE_RAW_DECL_WMEMPCPY
980 _GL_WARN_ON_USE (wmempcpy
, "wmempcpy is unportable - "
981 "use gnulib module wmempcpy for portability");
986 /* Set N wide characters of S to C. */
989 _GL_FUNCDECL_SYS (wmemset
, wchar_t *, (wchar_t *s
, wchar_t c
, size_t n
));
991 _GL_CXXALIAS_SYS (wmemset
, wchar_t *, (wchar_t *s
, wchar_t c
, size_t n
));
993 _GL_CXXALIASWARN (wmemset
);
995 #elif defined GNULIB_POSIXCHECK
997 # if HAVE_RAW_DECL_WMEMSET
998 _GL_WARN_ON_USE (wmemset
, "wmemset is unportable - "
999 "use gnulib module wmemset for portability");
1004 /* Return the number of wide characters in S. */
1007 _GL_FUNCDECL_SYS (wcslen
, size_t, (const wchar_t *s
) _GL_ATTRIBUTE_PURE
);
1009 _GL_CXXALIAS_SYS (wcslen
, size_t, (const wchar_t *s
));
1011 _GL_CXXALIASWARN (wcslen
);
1013 #elif defined GNULIB_POSIXCHECK
1015 # if HAVE_RAW_DECL_WCSLEN
1016 _GL_WARN_ON_USE (wcslen
, "wcslen is unportable - "
1017 "use gnulib module wcslen for portability");
1022 /* Return the number of wide characters in S, but at most MAXLEN. */
1023 #if @GNULIB_WCSNLEN@
1024 /* On Solaris 11.3, the header files declare the function in the std::
1025 namespace, not in the global namespace. So, force a declaration in
1026 the global namespace. */
1027 # if !@HAVE_WCSNLEN@ || (defined __sun && defined __cplusplus)
1028 _GL_FUNCDECL_SYS (wcsnlen
, size_t, (const wchar_t *s
, size_t maxlen
)
1029 _GL_ATTRIBUTE_PURE
);
1031 _GL_CXXALIAS_SYS (wcsnlen
, size_t, (const wchar_t *s
, size_t maxlen
));
1032 _GL_CXXALIASWARN (wcsnlen
);
1033 #elif defined GNULIB_POSIXCHECK
1035 # if HAVE_RAW_DECL_WCSNLEN
1036 _GL_WARN_ON_USE (wcsnlen
, "wcsnlen is unportable - "
1037 "use gnulib module wcsnlen for portability");
1042 /* Copy SRC to DEST. */
1045 _GL_FUNCDECL_SYS (wcscpy
, wchar_t *,
1046 (wchar_t *restrict dest
, const wchar_t *restrict src
));
1048 _GL_CXXALIAS_SYS (wcscpy
, wchar_t *,
1049 (wchar_t *restrict dest
, const wchar_t *restrict src
));
1051 _GL_CXXALIASWARN (wcscpy
);
1053 #elif defined GNULIB_POSIXCHECK
1055 # if HAVE_RAW_DECL_WCSCPY
1056 _GL_WARN_ON_USE (wcscpy
, "wcscpy is unportable - "
1057 "use gnulib module wcscpy for portability");
1062 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
1064 /* On Solaris 11.3, the header files declare the function in the std::
1065 namespace, not in the global namespace. So, force a declaration in
1066 the global namespace. */
1067 # if !@HAVE_WCPCPY@ || (defined __sun && defined __cplusplus)
1068 _GL_FUNCDECL_SYS (wcpcpy
, wchar_t *,
1069 (wchar_t *restrict dest
, const wchar_t *restrict src
));
1071 _GL_CXXALIAS_SYS (wcpcpy
, wchar_t *,
1072 (wchar_t *restrict dest
, const wchar_t *restrict src
));
1073 _GL_CXXALIASWARN (wcpcpy
);
1074 #elif defined GNULIB_POSIXCHECK
1076 # if HAVE_RAW_DECL_WCPCPY
1077 _GL_WARN_ON_USE (wcpcpy
, "wcpcpy is unportable - "
1078 "use gnulib module wcpcpy for portability");
1083 /* Copy no more than N wide characters of SRC to DEST. */
1084 #if @GNULIB_WCSNCPY@
1085 # if !@HAVE_WCSNCPY@
1086 _GL_FUNCDECL_SYS (wcsncpy
, wchar_t *,
1087 (wchar_t *restrict dest
,
1088 const wchar_t *restrict src
, size_t n
));
1090 _GL_CXXALIAS_SYS (wcsncpy
, wchar_t *,
1091 (wchar_t *restrict dest
,
1092 const wchar_t *restrict src
, size_t n
));
1094 _GL_CXXALIASWARN (wcsncpy
);
1096 #elif defined GNULIB_POSIXCHECK
1098 # if HAVE_RAW_DECL_WCSNCPY
1099 _GL_WARN_ON_USE (wcsncpy
, "wcsncpy is unportable - "
1100 "use gnulib module wcsncpy for portability");
1105 /* Copy no more than N characters of SRC to DEST, returning the address of
1106 the last character written into DEST. */
1107 #if @GNULIB_WCPNCPY@
1108 /* On Solaris 11.3, the header files declare the function in the std::
1109 namespace, not in the global namespace. So, force a declaration in
1110 the global namespace. */
1111 # if !@HAVE_WCPNCPY@ || (defined __sun && defined __cplusplus)
1112 _GL_FUNCDECL_SYS (wcpncpy
, wchar_t *,
1113 (wchar_t *restrict dest
,
1114 const wchar_t *restrict src
, size_t n
));
1116 _GL_CXXALIAS_SYS (wcpncpy
, wchar_t *,
1117 (wchar_t *restrict dest
,
1118 const wchar_t *restrict src
, size_t n
));
1119 _GL_CXXALIASWARN (wcpncpy
);
1120 #elif defined GNULIB_POSIXCHECK
1122 # if HAVE_RAW_DECL_WCPNCPY
1123 _GL_WARN_ON_USE (wcpncpy
, "wcpncpy is unportable - "
1124 "use gnulib module wcpncpy for portability");
1129 /* Append SRC onto DEST. */
1132 _GL_FUNCDECL_SYS (wcscat
, wchar_t *,
1133 (wchar_t *restrict dest
, const wchar_t *restrict src
));
1135 _GL_CXXALIAS_SYS (wcscat
, wchar_t *,
1136 (wchar_t *restrict dest
, const wchar_t *restrict src
));
1138 _GL_CXXALIASWARN (wcscat
);
1140 #elif defined GNULIB_POSIXCHECK
1142 # if HAVE_RAW_DECL_WCSCAT
1143 _GL_WARN_ON_USE (wcscat
, "wcscat is unportable - "
1144 "use gnulib module wcscat for portability");
1149 /* Append no more than N wide characters of SRC onto DEST. */
1150 #if @GNULIB_WCSNCAT@
1151 # if !@HAVE_WCSNCAT@
1152 _GL_FUNCDECL_SYS (wcsncat
, wchar_t *,
1153 (wchar_t *restrict dest
, const wchar_t *restrict src
,
1156 _GL_CXXALIAS_SYS (wcsncat
, wchar_t *,
1157 (wchar_t *restrict dest
, const wchar_t *restrict src
,
1160 _GL_CXXALIASWARN (wcsncat
);
1162 #elif defined GNULIB_POSIXCHECK
1164 # if HAVE_RAW_DECL_WCSNCAT
1165 _GL_WARN_ON_USE (wcsncat
, "wcsncat is unportable - "
1166 "use gnulib module wcsncat for portability");
1171 /* Compare S1 and S2. */
1173 # if @REPLACE_WCSCMP@
1174 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1176 # define wcscmp rpl_wcscmp
1178 _GL_FUNCDECL_RPL (wcscmp
, int, (const wchar_t *s1
, const wchar_t *s2
)
1179 _GL_ATTRIBUTE_PURE
);
1180 _GL_CXXALIAS_RPL (wcscmp
, int, (const wchar_t *s1
, const wchar_t *s2
));
1183 _GL_FUNCDECL_SYS (wcscmp
, int, (const wchar_t *s1
, const wchar_t *s2
)
1184 _GL_ATTRIBUTE_PURE
);
1186 _GL_CXXALIAS_SYS (wcscmp
, int, (const wchar_t *s1
, const wchar_t *s2
));
1189 _GL_CXXALIASWARN (wcscmp
);
1191 #elif defined GNULIB_POSIXCHECK
1193 # if HAVE_RAW_DECL_WCSCMP
1194 _GL_WARN_ON_USE (wcscmp
, "wcscmp is unportable - "
1195 "use gnulib module wcscmp for portability");
1200 /* Compare no more than N wide characters of S1 and S2. */
1201 #if @GNULIB_WCSNCMP@
1202 # if @REPLACE_WCSNCMP@
1203 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1205 # define wcsncmp rpl_wcsncmp
1207 _GL_FUNCDECL_RPL (wcsncmp
, int,
1208 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
1209 _GL_ATTRIBUTE_PURE
);
1210 _GL_CXXALIAS_RPL (wcsncmp
, int,
1211 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
1213 # if !@HAVE_WCSNCMP@
1214 _GL_FUNCDECL_SYS (wcsncmp
, int,
1215 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
1216 _GL_ATTRIBUTE_PURE
);
1218 _GL_CXXALIAS_SYS (wcsncmp
, int,
1219 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
1222 _GL_CXXALIASWARN (wcsncmp
);
1224 #elif defined GNULIB_POSIXCHECK
1226 # if HAVE_RAW_DECL_WCSNCMP
1227 _GL_WARN_ON_USE (wcsncmp
, "wcsncmp is unportable - "
1228 "use gnulib module wcsncmp for portability");
1233 /* Compare S1 and S2, ignoring case. */
1234 #if @GNULIB_WCSCASECMP@
1235 /* On Solaris 11.3, the header files declare the function in the std::
1236 namespace, not in the global namespace. So, force a declaration in
1237 the global namespace. */
1238 # if !@HAVE_WCSCASECMP@ || (defined __sun && defined __cplusplus)
1239 _GL_FUNCDECL_SYS (wcscasecmp
, int, (const wchar_t *s1
, const wchar_t *s2
)
1240 _GL_ATTRIBUTE_PURE
);
1242 _GL_CXXALIAS_SYS (wcscasecmp
, int, (const wchar_t *s1
, const wchar_t *s2
));
1243 _GL_CXXALIASWARN (wcscasecmp
);
1244 #elif defined GNULIB_POSIXCHECK
1246 # if HAVE_RAW_DECL_WCSCASECMP
1247 _GL_WARN_ON_USE (wcscasecmp
, "wcscasecmp is unportable - "
1248 "use gnulib module wcscasecmp for portability");
1253 /* Compare no more than N chars of S1 and S2, ignoring case. */
1254 #if @GNULIB_WCSNCASECMP@
1255 /* On Solaris 11.3, the header files declare the function in the std::
1256 namespace, not in the global namespace. So, force a declaration in
1257 the global namespace. */
1258 # if !@HAVE_WCSNCASECMP@ || (defined __sun && defined __cplusplus)
1259 _GL_FUNCDECL_SYS (wcsncasecmp
, int,
1260 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
1261 _GL_ATTRIBUTE_PURE
);
1263 _GL_CXXALIAS_SYS (wcsncasecmp
, int,
1264 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
1265 _GL_CXXALIASWARN (wcsncasecmp
);
1266 #elif defined GNULIB_POSIXCHECK
1268 # if HAVE_RAW_DECL_WCSNCASECMP
1269 _GL_WARN_ON_USE (wcsncasecmp
, "wcsncasecmp is unportable - "
1270 "use gnulib module wcsncasecmp for portability");
1275 /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
1276 category of the current locale. */
1277 #if @GNULIB_WCSCOLL@
1278 # if !@HAVE_WCSCOLL@
1279 _GL_FUNCDECL_SYS (wcscoll
, int, (const wchar_t *s1
, const wchar_t *s2
));
1281 _GL_CXXALIAS_SYS (wcscoll
, int, (const wchar_t *s1
, const wchar_t *s2
));
1283 _GL_CXXALIASWARN (wcscoll
);
1285 #elif defined GNULIB_POSIXCHECK
1287 # if HAVE_RAW_DECL_WCSCOLL
1288 _GL_WARN_ON_USE (wcscoll
, "wcscoll is unportable - "
1289 "use gnulib module wcscoll for portability");
1294 /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
1295 to two transformed strings the result is the as applying 'wcscoll' to the
1296 original strings. */
1297 #if @GNULIB_WCSXFRM@
1298 # if !@HAVE_WCSXFRM@
1299 _GL_FUNCDECL_SYS (wcsxfrm
, size_t,
1300 (wchar_t *restrict s1
, const wchar_t *restrict s2
, size_t n
));
1302 _GL_CXXALIAS_SYS (wcsxfrm
, size_t,
1303 (wchar_t *restrict s1
, const wchar_t *restrict s2
, size_t n
));
1305 _GL_CXXALIASWARN (wcsxfrm
);
1307 #elif defined GNULIB_POSIXCHECK
1309 # if HAVE_RAW_DECL_WCSXFRM
1310 _GL_WARN_ON_USE (wcsxfrm
, "wcsxfrm is unportable - "
1311 "use gnulib module wcsxfrm for portability");
1316 /* Duplicate S, returning an identical malloc'd string. */
1318 # if defined _WIN32 && !defined __CYGWIN__
1319 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1321 # define wcsdup _wcsdup
1323 _GL_CXXALIAS_MDA (wcsdup
, wchar_t *, (const wchar_t *s
));
1325 /* On Solaris 11.3, the header files declare the function in the std::
1326 namespace, not in the global namespace. So, force a declaration in
1327 the global namespace. */
1328 # if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11
1329 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1330 _GL_FUNCDECL_SYS (wcsdup
, wchar_t *,
1332 _GL_ATTRIBUTE_NOTHROW
1333 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
1335 _GL_FUNCDECL_SYS (wcsdup
, wchar_t *,
1337 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
1340 _GL_CXXALIAS_SYS (wcsdup
, wchar_t *, (const wchar_t *s
));
1342 _GL_CXXALIASWARN (wcsdup
);
1344 # if __GNUC__ >= 11 && !defined wcsdup
1345 /* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */
1346 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1347 _GL_FUNCDECL_SYS (wcsdup
, wchar_t *,
1349 _GL_ATTRIBUTE_NOTHROW
1350 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
1352 _GL_FUNCDECL_SYS (wcsdup
, wchar_t *,
1354 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
1357 # if defined GNULIB_POSIXCHECK
1359 # if HAVE_RAW_DECL_WCSDUP
1360 _GL_WARN_ON_USE (wcsdup
, "wcsdup is unportable - "
1361 "use gnulib module wcsdup for portability");
1363 # elif @GNULIB_MDA_WCSDUP@
1364 /* On native Windows, map 'wcsdup' to '_wcsdup', so that -loldnames is not
1365 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1366 platforms by defining GNULIB_NAMESPACE::wcsdup always. */
1367 # if defined _WIN32 && !defined __CYGWIN__
1368 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1370 # define wcsdup _wcsdup
1372 _GL_CXXALIAS_MDA (wcsdup
, wchar_t *, (const wchar_t *s
));
1374 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1375 _GL_FUNCDECL_SYS (wcsdup
, wchar_t *,
1377 _GL_ATTRIBUTE_NOTHROW
1378 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
1380 _GL_FUNCDECL_SYS (wcsdup
, wchar_t *,
1382 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
1384 # if @HAVE_DECL_WCSDUP@
1385 _GL_CXXALIAS_SYS (wcsdup
, wchar_t *, (const wchar_t *s
));
1388 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_WCSDUP@
1389 _GL_CXXALIASWARN (wcsdup
);
1395 /* Find the first occurrence of WC in WCS. */
1398 _GL_FUNCDECL_SYS (wcschr
, wchar_t *, (const wchar_t *wcs
, wchar_t wc
)
1399 _GL_ATTRIBUTE_PURE
);
1401 /* On some systems, this function is defined as an overloaded function:
1403 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
1404 wchar_t * std::wcschr (wchar_t *, wchar_t);
1406 _GL_CXXALIAS_SYS_CAST2 (wcschr
,
1407 wchar_t *, (const wchar_t *, wchar_t),
1408 const wchar_t *, (const wchar_t *, wchar_t));
1409 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1410 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1411 _GL_CXXALIASWARN1 (wcschr
, wchar_t *, (wchar_t *wcs
, wchar_t wc
));
1412 _GL_CXXALIASWARN1 (wcschr
, const wchar_t *, (const wchar_t *wcs
, wchar_t wc
));
1413 # elif __GLIBC__ >= 2
1414 _GL_CXXALIASWARN (wcschr
);
1416 #elif defined GNULIB_POSIXCHECK
1418 # if HAVE_RAW_DECL_WCSCHR
1419 _GL_WARN_ON_USE (wcschr
, "wcschr is unportable - "
1420 "use gnulib module wcschr for portability");
1425 /* Find the last occurrence of WC in WCS. */
1426 #if @GNULIB_WCSRCHR@
1427 # if !@HAVE_WCSRCHR@
1428 _GL_FUNCDECL_SYS (wcsrchr
, wchar_t *, (const wchar_t *wcs
, wchar_t wc
)
1429 _GL_ATTRIBUTE_PURE
);
1431 /* On some systems, this function is defined as an overloaded function:
1433 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
1434 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
1436 _GL_CXXALIAS_SYS_CAST2 (wcsrchr
,
1437 wchar_t *, (const wchar_t *, wchar_t),
1438 const wchar_t *, (const wchar_t *, wchar_t));
1439 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1440 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1441 _GL_CXXALIASWARN1 (wcsrchr
, wchar_t *, (wchar_t *wcs
, wchar_t wc
));
1442 _GL_CXXALIASWARN1 (wcsrchr
, const wchar_t *, (const wchar_t *wcs
, wchar_t wc
));
1443 # elif __GLIBC__ >= 2
1444 _GL_CXXALIASWARN (wcsrchr
);
1446 #elif defined GNULIB_POSIXCHECK
1448 # if HAVE_RAW_DECL_WCSRCHR
1449 _GL_WARN_ON_USE (wcsrchr
, "wcsrchr is unportable - "
1450 "use gnulib module wcsrchr for portability");
1455 /* Return the length of the initial segment of WCS which consists entirely
1456 of wide characters not in REJECT. */
1457 #if @GNULIB_WCSCSPN@
1458 # if !@HAVE_WCSCSPN@
1459 _GL_FUNCDECL_SYS (wcscspn
, size_t, (const wchar_t *wcs
, const wchar_t *reject
)
1460 _GL_ATTRIBUTE_PURE
);
1462 _GL_CXXALIAS_SYS (wcscspn
, size_t, (const wchar_t *wcs
, const wchar_t *reject
));
1464 _GL_CXXALIASWARN (wcscspn
);
1466 #elif defined GNULIB_POSIXCHECK
1468 # if HAVE_RAW_DECL_WCSCSPN
1469 _GL_WARN_ON_USE (wcscspn
, "wcscspn is unportable - "
1470 "use gnulib module wcscspn for portability");
1475 /* Return the length of the initial segment of WCS which consists entirely
1476 of wide characters in ACCEPT. */
1479 _GL_FUNCDECL_SYS (wcsspn
, size_t, (const wchar_t *wcs
, const wchar_t *accept
)
1480 _GL_ATTRIBUTE_PURE
);
1482 _GL_CXXALIAS_SYS (wcsspn
, size_t, (const wchar_t *wcs
, const wchar_t *accept
));
1484 _GL_CXXALIASWARN (wcsspn
);
1486 #elif defined GNULIB_POSIXCHECK
1488 # if HAVE_RAW_DECL_WCSSPN
1489 _GL_WARN_ON_USE (wcsspn
, "wcsspn is unportable - "
1490 "use gnulib module wcsspn for portability");
1495 /* Find the first occurrence in WCS of any character in ACCEPT. */
1496 #if @GNULIB_WCSPBRK@
1497 # if !@HAVE_WCSPBRK@
1498 _GL_FUNCDECL_SYS (wcspbrk
, wchar_t *,
1499 (const wchar_t *wcs
, const wchar_t *accept
)
1500 _GL_ATTRIBUTE_PURE
);
1502 /* On some systems, this function is defined as an overloaded function:
1504 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
1505 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
1507 _GL_CXXALIAS_SYS_CAST2 (wcspbrk
,
1508 wchar_t *, (const wchar_t *, const wchar_t *),
1509 const wchar_t *, (const wchar_t *, const wchar_t *));
1510 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1511 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1512 _GL_CXXALIASWARN1 (wcspbrk
, wchar_t *,
1513 (wchar_t *wcs
, const wchar_t *accept
));
1514 _GL_CXXALIASWARN1 (wcspbrk
, const wchar_t *,
1515 (const wchar_t *wcs
, const wchar_t *accept
));
1516 # elif __GLIBC__ >= 2
1517 _GL_CXXALIASWARN (wcspbrk
);
1519 #elif defined GNULIB_POSIXCHECK
1521 # if HAVE_RAW_DECL_WCSPBRK
1522 _GL_WARN_ON_USE (wcspbrk
, "wcspbrk is unportable - "
1523 "use gnulib module wcspbrk for portability");
1528 /* Find the first occurrence of NEEDLE in HAYSTACK. */
1530 # if @REPLACE_WCSSTR@
1531 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1533 # define wcsstr rpl_wcsstr
1535 _GL_FUNCDECL_RPL (wcsstr
, wchar_t *,
1536 (const wchar_t *restrict haystack
,
1537 const wchar_t *restrict needle
)
1538 _GL_ATTRIBUTE_PURE
);
1539 _GL_CXXALIAS_RPL (wcsstr
, wchar_t *,
1540 (const wchar_t *restrict haystack
,
1541 const wchar_t *restrict needle
));
1544 _GL_FUNCDECL_SYS (wcsstr
, wchar_t *,
1545 (const wchar_t *restrict haystack
,
1546 const wchar_t *restrict needle
)
1547 _GL_ATTRIBUTE_PURE
);
1549 /* On some systems, this function is defined as an overloaded function:
1551 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
1552 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
1554 _GL_CXXALIAS_SYS_CAST2 (wcsstr
,
1556 (const wchar_t *restrict
, const wchar_t *restrict
),
1558 (const wchar_t *restrict
, const wchar_t *restrict
));
1560 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1561 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1562 _GL_CXXALIASWARN1 (wcsstr
, wchar_t *,
1563 (wchar_t *restrict haystack
,
1564 const wchar_t *restrict needle
));
1565 _GL_CXXALIASWARN1 (wcsstr
, const wchar_t *,
1566 (const wchar_t *restrict haystack
,
1567 const wchar_t *restrict needle
));
1568 # elif __GLIBC__ >= 2
1569 _GL_CXXALIASWARN (wcsstr
);
1571 #elif defined GNULIB_POSIXCHECK
1573 # if HAVE_RAW_DECL_WCSSTR
1574 _GL_WARN_ON_USE (wcsstr
, "wcsstr is unportable - "
1575 "use gnulib module wcsstr for portability");
1580 /* Divide WCS into tokens separated by characters in DELIM. */
1582 # if @REPLACE_WCSTOK@
1583 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1585 # define wcstok rpl_wcstok
1587 _GL_FUNCDECL_RPL (wcstok
, wchar_t *,
1588 (wchar_t *restrict wcs
, const wchar_t *restrict delim
,
1589 wchar_t **restrict ptr
));
1590 _GL_CXXALIAS_RPL (wcstok
, wchar_t *,
1591 (wchar_t *restrict wcs
, const wchar_t *restrict delim
,
1592 wchar_t **restrict ptr
));
1595 _GL_FUNCDECL_SYS (wcstok
, wchar_t *,
1596 (wchar_t *restrict wcs
, const wchar_t *restrict delim
,
1597 wchar_t **restrict ptr
));
1599 _GL_CXXALIAS_SYS (wcstok
, wchar_t *,
1600 (wchar_t *restrict wcs
, const wchar_t *restrict delim
,
1601 wchar_t **restrict ptr
));
1604 _GL_CXXALIASWARN (wcstok
);
1606 #elif defined GNULIB_POSIXCHECK
1608 # if HAVE_RAW_DECL_WCSTOK
1609 _GL_WARN_ON_USE (wcstok
, "wcstok is unportable - "
1610 "use gnulib module wcstok for portability");
1615 /* Determine number of column positions required for first N wide
1616 characters (or fewer if S ends before this) in S. */
1617 #if @GNULIB_WCSWIDTH@
1618 # if @REPLACE_WCSWIDTH@
1619 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1621 # define wcswidth rpl_wcswidth
1623 _GL_FUNCDECL_RPL (wcswidth
, int, (const wchar_t *s
, size_t n
)
1624 _GL_ATTRIBUTE_PURE
);
1625 _GL_CXXALIAS_RPL (wcswidth
, int, (const wchar_t *s
, size_t n
));
1627 # if !@HAVE_WCSWIDTH@
1628 _GL_FUNCDECL_SYS (wcswidth
, int, (const wchar_t *s
, size_t n
)
1629 _GL_ATTRIBUTE_PURE
);
1631 _GL_CXXALIAS_SYS (wcswidth
, int, (const wchar_t *s
, size_t n
));
1634 _GL_CXXALIASWARN (wcswidth
);
1636 #elif defined GNULIB_POSIXCHECK
1638 # if HAVE_RAW_DECL_WCSWIDTH
1639 _GL_WARN_ON_USE (wcswidth
, "wcswidth is unportable - "
1640 "use gnulib module wcswidth for portability");
1645 /* Convert *TP to a date and time wide string. See
1646 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
1647 #if @GNULIB_WCSFTIME@
1648 # if @REPLACE_WCSFTIME@
1649 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1651 # define wcsftime rpl_wcsftime
1653 _GL_FUNCDECL_RPL (wcsftime
, size_t,
1654 (wchar_t *restrict __buf
, size_t __bufsize
,
1655 const wchar_t *restrict __fmt
,
1656 const struct tm
*restrict __tp
)
1657 _GL_ARG_NONNULL ((1, 3, 4)));
1658 _GL_CXXALIAS_RPL (wcsftime
, size_t,
1659 (wchar_t *restrict __buf
, size_t __bufsize
,
1660 const wchar_t *restrict __fmt
,
1661 const struct tm
*restrict __tp
));
1663 # if !@HAVE_WCSFTIME@
1664 _GL_FUNCDECL_SYS (wcsftime
, size_t,
1665 (wchar_t *restrict __buf
, size_t __bufsize
,
1666 const wchar_t *restrict __fmt
,
1667 const struct tm
*restrict __tp
)
1668 _GL_ARG_NONNULL ((1, 3, 4)));
1670 _GL_CXXALIAS_SYS (wcsftime
, size_t,
1671 (wchar_t *restrict __buf
, size_t __bufsize
,
1672 const wchar_t *restrict __fmt
,
1673 const struct tm
*restrict __tp
));
1676 _GL_CXXALIASWARN (wcsftime
);
1678 #elif defined GNULIB_POSIXCHECK
1680 # if HAVE_RAW_DECL_WCSFTIME
1681 _GL_WARN_ON_USE (wcsftime
, "wcsftime is unportable - "
1682 "use gnulib module wcsftime for portability");
1687 #if @GNULIB_WGETCWD@ && (defined _WIN32 && !defined __CYGWIN__)
1688 /* Gets the name of the current working directory.
1689 (a) If BUF is non-NULL, it is assumed to have room for SIZE wide characters.
1690 This function stores the working directory (NUL-terminated) in BUF and
1692 (b) If BUF is NULL, an array is allocated with 'malloc'. The array is SIZE
1693 wide characters long, unless SIZE == 0, in which case it is as big as
1695 If the directory couldn't be determined or SIZE was too small, this function
1696 returns NULL and sets errno. For a directory of length LEN, SIZE should be
1697 >= LEN + 3 in case (a) or >= LEN + 1 in case (b).
1698 Possible errno values include:
1699 - ERANGE if SIZE is too small.
1700 - ENOMEM if the memory could no be allocated. */
1701 _GL_FUNCDECL_SYS (wgetcwd
, wchar_t *, (wchar_t *buf
, size_t size
));
1705 #endif /* _@GUARD_PREFIX@_WCHAR_H */
1706 #endif /* _@GUARD_PREFIX@_WCHAR_H */