summaryrefslogtreecommitdiffstats
path: root/gl/wchar.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/wchar.in.h')
-rw-r--r--gl/wchar.in.h645
1 files changed, 548 insertions, 97 deletions
diff --git a/gl/wchar.in.h b/gl/wchar.in.h
index 09c9185f..a6c52eb9 100644
--- a/gl/wchar.in.h
+++ b/gl/wchar.in.h
@@ -1,6 +1,6 @@
1/* A substitute for ISO C99 <wchar.h>, for platforms that have issues. 1/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
2 2
3 Copyright (C) 2007-2023 Free Software Foundation, Inc. 3 Copyright (C) 2007-2025 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 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 6 it under the terms of the GNU Lesser General Public License as
@@ -37,7 +37,7 @@
37 && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \ 37 && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \
38 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \ 38 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
39 || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \ 39 || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
40 || defined _GL_ALREADY_INCLUDING_WCHAR_H) 40 || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_WCHAR_H)
41/* Special invocation convention: 41/* Special invocation convention:
42 - Inside glibc and uClibc header files, but not MinGW. 42 - Inside glibc and uClibc header files, but not MinGW.
43 - On HP-UX 11.00 we have a sequence of nested includes 43 - On HP-UX 11.00 we have a sequence of nested includes
@@ -53,13 +53,16 @@
53 <wctype.h> is completely included or is still being included. */ 53 <wctype.h> is completely included or is still being included. */
54 54
55#@INCLUDE_NEXT@ @NEXT_WCHAR_H@ 55#@INCLUDE_NEXT@ @NEXT_WCHAR_H@
56/* The glibc 2.5 /usr/include/wchar.h defines __need_wint_t but never undefines
57 it. We need to do that here. */
58#undef __need_wint_t
56 59
57#else 60#else
58/* Normal invocation convention. */ 61/* Normal invocation convention. */
59 62
60#ifndef _@GUARD_PREFIX@_WCHAR_H 63#ifndef _@GUARD_PREFIX@_WCHAR_H
61 64
62#define _GL_ALREADY_INCLUDING_WCHAR_H 65#define _@GUARD_PREFIX@_ALREADY_INCLUDING_WCHAR_H
63 66
64#if @HAVE_FEATURES_H@ 67#if @HAVE_FEATURES_H@
65# include <features.h> /* for __GLIBC__ */ 68# include <features.h> /* for __GLIBC__ */
@@ -79,16 +82,23 @@
79# @INCLUDE_NEXT@ @NEXT_WCHAR_H@ 82# @INCLUDE_NEXT@ @NEXT_WCHAR_H@
80#endif 83#endif
81 84
82#undef _GL_ALREADY_INCLUDING_WCHAR_H 85#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_WCHAR_H
83 86
84#ifndef _@GUARD_PREFIX@_WCHAR_H 87#ifndef _@GUARD_PREFIX@_WCHAR_H
85#define _@GUARD_PREFIX@_WCHAR_H 88#define _@GUARD_PREFIX@_WCHAR_H
86 89
90/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
91 _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
92 HAVE_RAW_DECL_*. */
93#if !_GL_CONFIG_H_INCLUDED
94 #error "Please include config.h first."
95#endif
96
87/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers 97/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
88 that can be freed by passing them as the Ith argument to the 98 that can be freed by passing them as the Ith argument to the
89 function F. */ 99 function F. */
90#ifndef _GL_ATTRIBUTE_DEALLOC 100#ifndef _GL_ATTRIBUTE_DEALLOC
91# if __GNUC__ >= 11 101# if __GNUC__ >= 11 && !defined __clang__
92# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) 102# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
93# else 103# else
94# define _GL_ATTRIBUTE_DEALLOC(f, i) 104# define _GL_ATTRIBUTE_DEALLOC(f, i)
@@ -130,6 +140,40 @@
130# endif 140# endif
131#endif 141#endif
132 142
143/* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP
144 (a pointer) must not be NULL if the argument NI (an integer) is != 0. */
145/* Applies to: functions. */
146#ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO
147# if __GNUC__ >= 15 && !defined __clang__
148# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) \
149 __attribute__ ((__nonnull_if_nonzero__ (np, ni)))
150# else
151# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni)
152# endif
153#endif
154
155/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
156 */
157#ifndef _GL_ATTRIBUTE_NOTHROW
158# if defined __cplusplus
159# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
160# if __cplusplus >= 201103L
161# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
162# else
163# define _GL_ATTRIBUTE_NOTHROW throw ()
164# endif
165# else
166# define _GL_ATTRIBUTE_NOTHROW
167# endif
168# else
169# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
170# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
171# else
172# define _GL_ATTRIBUTE_NOTHROW
173# endif
174# endif
175#endif
176
133/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 177/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
134 178
135/* The definition of _GL_ARG_NONNULL is copied here. */ 179/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -169,11 +213,12 @@ typedef unsigned int rpl_wint_t;
169/* Override mbstate_t if it is too small. 213/* Override mbstate_t if it is too small.
170 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for 214 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
171 implementing mbrtowc for encodings like UTF-8. 215 implementing mbrtowc for encodings like UTF-8.
172 On AIX and MSVC, mbrtowc needs to be overridden, but mbstate_t exists and is 216 On AIX, MSVC, and OpenBSD 6.0, mbrtowc needs to be overridden, but
173 large enough and overriding it would cause problems in C++ mode. */ 217 mbstate_t exists and is large enough and overriding it would cause problems
218 in C++ mode. */
174#if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ 219#if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
175# if !GNULIB_defined_mbstate_t 220# if !GNULIB_defined_mbstate_t
176# if !(defined _AIX || defined _MSC_VER) 221# if !(defined _AIX || defined _MSC_VER || defined __OpenBSD__)
177typedef int rpl_mbstate_t; 222typedef int rpl_mbstate_t;
178# undef mbstate_t 223# undef mbstate_t
179# define mbstate_t rpl_mbstate_t 224# define mbstate_t rpl_mbstate_t
@@ -188,7 +233,11 @@ typedef int rpl_mbstate_t;
188# if (@REPLACE_FREE@ && !defined free \ 233# if (@REPLACE_FREE@ && !defined free \
189 && !(defined __cplusplus && defined GNULIB_NAMESPACE)) 234 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
190/* We can't do '#define free rpl_free' here. */ 235/* We can't do '#define free rpl_free' here. */
236# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
237_GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW;
238# else
191_GL_EXTERN_C void rpl_free (void *); 239_GL_EXTERN_C void rpl_free (void *);
240# endif
192# undef _GL_ATTRIBUTE_DEALLOC_FREE 241# undef _GL_ATTRIBUTE_DEALLOC_FREE
193# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) 242# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
194# else 243# else
@@ -200,7 +249,7 @@ _GL_EXTERN_C
200 void __cdecl free (void *); 249 void __cdecl free (void *);
201# else 250# else
202# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 251# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
203_GL_EXTERN_C void free (void *) throw (); 252_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
204# else 253# else
205_GL_EXTERN_C void free (void *); 254_GL_EXTERN_C void free (void *);
206# endif 255# endif
@@ -215,13 +264,69 @@ _GL_EXTERN_C
215 void __cdecl free (void *); 264 void __cdecl free (void *);
216# else 265# else
217# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 266# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
218_GL_EXTERN_C void free (void *) throw (); 267_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
219# else 268# else
220_GL_EXTERN_C void free (void *); 269_GL_EXTERN_C void free (void *);
221# endif 270# endif
222# endif 271# endif
223#endif 272#endif
224 273
274
275#if @GNULIB_MBSZERO@
276/* Get memset(). */
277# include <string.h>
278#endif
279
280
281/* Declarations for ISO C N3322. */
282#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
283_GL_EXTERN_C wchar_t *wmemcpy (wchar_t *__dest, const wchar_t *__src, size_t __n)
284# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
285 _GL_ATTRIBUTE_NOTHROW
286# endif
287 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
288 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
289_GL_EXTERN_C wchar_t *wmemmove (wchar_t *__dest, const wchar_t *__src, size_t __n)
290# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
291 _GL_ATTRIBUTE_NOTHROW
292# endif
293 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
294 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
295_GL_EXTERN_C wchar_t *wcsncpy (wchar_t *__dest, const wchar_t *__src, size_t __n)
296# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
297 _GL_ATTRIBUTE_NOTHROW
298# endif
299 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
300 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
301_GL_EXTERN_C wchar_t *wcsncat (wchar_t *__dest, const wchar_t *__src, size_t __n)
302# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
303 _GL_ATTRIBUTE_NOTHROW
304# endif
305 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
306_GL_EXTERN_C int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
307# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
308 _GL_ATTRIBUTE_NOTHROW
309# endif
310 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
311 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
312_GL_EXTERN_C int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
313# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
314 _GL_ATTRIBUTE_NOTHROW
315# endif
316 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
317 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
318# ifndef __cplusplus
319_GL_EXTERN_C wchar_t *wmemchr (const wchar_t *__s, wchar_t __wc, size_t __n)
320 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
321# endif
322_GL_EXTERN_C wchar_t *wmemset (wchar_t *__s, wchar_t __wc, size_t __n)
323# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
324 _GL_ATTRIBUTE_NOTHROW
325# endif
326 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
327#endif
328
329
225/* Convert a single-byte character to a wide character. */ 330/* Convert a single-byte character to a wide character. */
226#if @GNULIB_BTOWC@ 331#if @GNULIB_BTOWC@
227# if @REPLACE_BTOWC@ 332# if @REPLACE_BTOWC@
@@ -229,11 +334,11 @@ _GL_EXTERN_C void free (void *);
229# undef btowc 334# undef btowc
230# define btowc rpl_btowc 335# define btowc rpl_btowc
231# endif 336# endif
232_GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); 337_GL_FUNCDECL_RPL (btowc, wint_t, (int c), _GL_ATTRIBUTE_PURE);
233_GL_CXXALIAS_RPL (btowc, wint_t, (int c)); 338_GL_CXXALIAS_RPL (btowc, wint_t, (int c));
234# else 339# else
235# if !@HAVE_BTOWC@ 340# if !@HAVE_BTOWC@
236_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); 341_GL_FUNCDECL_SYS (btowc, wint_t, (int c), _GL_ATTRIBUTE_PURE);
237# endif 342# endif
238/* Need to cast, because on mingw, the return type is 'unsigned short'. */ 343/* Need to cast, because on mingw, the return type is 'unsigned short'. */
239_GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c)); 344_GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c));
@@ -257,12 +362,12 @@ _GL_WARN_ON_USE (btowc, "btowc is unportable - "
257# undef wctob 362# undef wctob
258# define wctob rpl_wctob 363# define wctob rpl_wctob
259# endif 364# endif
260_GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE); 365_GL_FUNCDECL_RPL (wctob, int, (wint_t wc), _GL_ATTRIBUTE_PURE);
261_GL_CXXALIAS_RPL (wctob, int, (wint_t wc)); 366_GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
262# else 367# else
263# if !defined wctob && !@HAVE_DECL_WCTOB@ 368# if !defined wctob && !@HAVE_DECL_WCTOB@
264/* wctob is provided by gnulib, or wctob exists but is not declared. */ 369/* wctob is provided by gnulib, or wctob exists but is not declared. */
265_GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE); 370_GL_FUNCDECL_SYS (wctob, int, (wint_t wc), _GL_ATTRIBUTE_PURE);
266# endif 371# endif
267_GL_CXXALIAS_SYS (wctob, int, (wint_t wc)); 372_GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
268# endif 373# endif
@@ -278,18 +383,18 @@ _GL_WARN_ON_USE (wctob, "wctob is unportable - "
278#endif 383#endif
279 384
280 385
281/* Test whether *PS is in the initial state. */ 386/* Test whether *PS is in an initial state. */
282#if @GNULIB_MBSINIT@ 387#if @GNULIB_MBSINIT@
283# if @REPLACE_MBSINIT@ 388# if @REPLACE_MBSINIT@
284# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 389# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
285# undef mbsinit 390# undef mbsinit
286# define mbsinit rpl_mbsinit 391# define mbsinit rpl_mbsinit
287# endif 392# endif
288_GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps)); 393_GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps), );
289_GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps)); 394_GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
290# else 395# else
291# if !@HAVE_MBSINIT@ 396# if !@HAVE_MBSINIT@
292_GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps)); 397_GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps), );
293# endif 398# endif
294_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps)); 399_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
295# endif 400# endif
@@ -305,6 +410,211 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
305#endif 410#endif
306 411
307 412
413/* Put *PS into an initial state. */
414#if @GNULIB_MBSZERO@
415/* ISO C 23 § 7.31.6.(3) says that zeroing an mbstate_t is a way to put the
416 mbstate_t into an initial state. However, on many platforms an mbstate_t
417 is large, and it is possible - as an optimization - to get away with zeroing
418 only part of it. So, instead of
419
420 mbstate_t state = { 0 };
421
422 or
423
424 mbstate_t state;
425 memset (&state, 0, sizeof (mbstate_t));
426
427 we can write this faster code:
428
429 mbstate_t state;
430 mbszero (&state);
431 */
432/* _GL_MBSTATE_INIT_SIZE describes how mbsinit() behaves: It is the number of
433 bytes at the beginning of an mbstate_t that need to be zero, for mbsinit()
434 to return true.
435 _GL_MBSTATE_ZERO_SIZE is the number of bytes at the beginning of an mbstate_t
436 that need to be zero,
437 - for mbsinit() to return true, and
438 - for all other multibyte-aware functions to operate properly.
439 0 < _GL_MBSTATE_INIT_SIZE <= _GL_MBSTATE_ZERO_SIZE <= sizeof (mbstate_t).
440 These values are determined by source code inspection, where possible, and
441 by running the gnulib unit tests.
442 We need _GL_MBSTATE_INIT_SIZE because if we define _GL_MBSTATE_ZERO_SIZE
443 without considering what mbsinit() does, we get test failures such as
444 assertion "mbsinit (&iter->state)" failed
445 */
446# if GNULIB_defined_mbstate_t /* AIX, IRIX */
447/* mbstate_t has at least 4 bytes. They are used as coded in
448 gnulib/lib/mbrtowc.c. */
449# define _GL_MBSTATE_INIT_SIZE 1
450/* define _GL_MBSTATE_ZERO_SIZE 4
451 does not work: it causes test failures.
452 So, use the safe fallback value, below. */
453# elif __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 /* glibc */
454/* mbstate_t is defined in <bits/types/__mbstate_t.h>.
455 For more details, see glibc/iconv/skeleton.c. */
456# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (((mbstate_t) {0}).__count) */
457# define _GL_MBSTATE_ZERO_SIZE /* 8 */ sizeof (mbstate_t)
458# elif defined MUSL_LIBC /* musl libc */
459/* mbstate_t is defined in <bits/alltypes.h>.
460 It is an opaque aligned 8-byte struct, of which at most the first
461 4 bytes are used.
462 For more details, see src/multibyte/mbrtowc.c. */
463# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (unsigned) */
464# define _GL_MBSTATE_ZERO_SIZE 4
465# elif defined __APPLE__ && defined __MACH__ /* macOS */
466/* On macOS, mbstate_t is defined in <machine/_types.h>.
467 It is an opaque aligned 128-byte struct, of which at most the first
468 12 bytes are used.
469 For more details, see the __mbsinit implementations in
470 Libc-<version>/locale/FreeBSD/
471 {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8,utf2}.c. */
472/* File INIT_SIZE ZERO_SIZE
473 ascii.c 0 0
474 none.c 0 0
475 euc.c 12 12
476 mskanji.c 4 4
477 big5.c 4 4
478 gb2312.c 4 6
479 gbk.c 4 4
480 gb18030.c 4 8
481 utf8.c 8 10
482 utf2.c 8 12 */
483# define _GL_MBSTATE_INIT_SIZE 12
484# define _GL_MBSTATE_ZERO_SIZE 12
485# elif defined __FreeBSD__ /* FreeBSD */
486/* On FreeBSD, mbstate_t is defined in src/sys/sys/_types.h.
487 It is an opaque aligned 128-byte struct, of which at most the first
488 12 bytes are used.
489 For more details, see the __mbsinit implementations in
490 src/lib/libc/locale/
491 {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
492/* File INIT_SIZE ZERO_SIZE
493 ascii.c 0 0
494 none.c 0 0
495 euc.c 12 12
496 mskanji.c 4 4
497 big5.c 4 4
498 gb2312.c 4 6
499 gbk.c 4 4
500 gb18030.c 4 8
501 utf8.c 8 12 */
502# define _GL_MBSTATE_INIT_SIZE 12
503# define _GL_MBSTATE_ZERO_SIZE 12
504# elif defined __NetBSD__ /* NetBSD */
505/* On NetBSD, mbstate_t is defined in src/sys/sys/ansi.h.
506 It is an opaque aligned 128-byte struct, of which at most the first
507 28 bytes are used.
508 For more details, see the *State types in
509 src/lib/libc/citrus/modules/citrus_*.c
510 (ignoring citrus_{hz,iso2022,utf7,viqr,zw}.c, since these implement
511 stateful encodings, not usable as locale encodings). */
512/* File ZERO_SIZE
513 citrus/citrus_none.c 0
514 citrus/modules/citrus_euc.c 8
515 citrus/modules/citrus_euctw.c 8
516 citrus/modules/citrus_mskanji.c 8
517 citrus/modules/citrus_big5.c 8
518 citrus/modules/citrus_gbk2k.c 8
519 citrus/modules/citrus_dechanyu.c 8
520 citrus/modules/citrus_johab.c 6
521 citrus/modules/citrus_utf8.c 12 */
522/* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
523 failures for values < 28. */
524# define _GL_MBSTATE_ZERO_SIZE 28
525# elif defined __OpenBSD__ /* OpenBSD */
526/* On OpenBSD, mbstate_t is defined in src/sys/sys/_types.h.
527 It is an opaque aligned 128-byte struct, of which at most the first
528 12 bytes are used.
529 For more details, see src/lib/libc/citrus/citrus_*.c. */
530/* File INIT_SIZE ZERO_SIZE
531 citrus_none.c 0 0
532 citrus_utf8.c 12 12 */
533# define _GL_MBSTATE_INIT_SIZE 12
534# define _GL_MBSTATE_ZERO_SIZE 12
535# elif defined __minix /* Minix */
536/* On Minix, mbstate_t is defined in sys/sys/ansi.h.
537 It is an opaque aligned 128-byte struct.
538 For more details, see the *State types in
539 lib/libc/citrus/citrus_*.c. */
540/* File INIT_SIZE ZERO_SIZE
541 citrus_none.c 0 0 */
542/* But 1 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
543 failures for values < 4. */
544# define _GL_MBSTATE_ZERO_SIZE 4
545# elif defined __sun /* Solaris */
546/* On Solaris, mbstate_t is defined in <wchar_impl.h>.
547 It is an opaque aligned 24-byte or 32-byte struct, of which at most the first
548 20 or 28 bytes are used.
549 For more details on OpenSolaris derivatives, see the *State types in
550 illumos-gate/usr/src/lib/libc/port/locale/
551 {none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
552/* File INIT_SIZE ZERO_SIZE
553 none.c 0 0
554 euc.c 12 12
555 mskanji.c 4 4
556 big5.c 4 4
557 gb2312.c 4 6
558 gbk.c 4 4
559 gb18030.c 4 8
560 utf8.c 12 12 */
561/* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
562 failures
563 - in OpenIndiana and OmniOS: for values < 16,
564 - in Solaris 10 and 11: for values < 20 (in 32-bit mode)
565 or < 28 (in 64-bit mode).
566 Since we don't have a good way to distinguish the OpenSolaris derivatives
567 from the proprietary Solaris versions, and can't inspect the Solaris source
568 code, use the safe fallback values, below. */
569# elif defined __CYGWIN__ /* Cygwin */
570/* On Cygwin, mbstate_t is defined in <sys/_types.h>.
571 For more details, see newlib/libc/stdlib/mbtowc_r.c and
572 winsup/cygwin/strfuncs.cc. */
573# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (int) */
574# define _GL_MBSTATE_ZERO_SIZE 8
575# elif defined _WIN32 && !defined __CYGWIN__ /* Native Windows. */
576/* MSVC defines 'mbstate_t' as an aligned 8-byte struct.
577 On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined
578 as an aligned 8-byte struct, of which the first 4 bytes matter.
579 Use the safe values, below. */
580# elif defined __ANDROID__ /* Android */
581/* Android defines 'mbstate_t' in <bits/mbstate_t.h>.
582 It is an opaque 4-byte or 8-byte struct.
583 For more details, see
584 bionic/libc/private/bionic_mbstate.h
585 bionic/libc/bionic/mbrtoc32.cpp
586 bionic/libc/bionic/mbrtoc16.cpp
587 */
588# define _GL_MBSTATE_INIT_SIZE 4
589# define _GL_MBSTATE_ZERO_SIZE 4
590# endif
591/* Use safe values as defaults. */
592# ifndef _GL_MBSTATE_INIT_SIZE
593# define _GL_MBSTATE_INIT_SIZE sizeof (mbstate_t)
594# endif
595# ifndef _GL_MBSTATE_ZERO_SIZE
596# define _GL_MBSTATE_ZERO_SIZE sizeof (mbstate_t)
597# endif
598_GL_BEGIN_C_LINKAGE
599# if !GNULIB_defined_mbszero
600# if defined IN_MBSZERO
601_GL_EXTERN_INLINE
602# else
603_GL_INLINE
604# endif
605_GL_ARG_NONNULL ((1)) void
606mbszero (mbstate_t *ps)
607{
608 memset (ps, 0, _GL_MBSTATE_ZERO_SIZE);
609}
610# define GNULIB_defined_mbszero 1
611# endif
612_GL_END_C_LINKAGE
613_GL_CXXALIAS_SYS (mbszero, void, (mbstate_t *ps));
614_GL_CXXALIASWARN (mbszero);
615#endif
616
617
308/* Convert a multibyte character to a wide character. */ 618/* Convert a multibyte character to a wide character. */
309#if @GNULIB_MBRTOWC@ 619#if @GNULIB_MBRTOWC@
310# if @REPLACE_MBRTOWC@ 620# if @REPLACE_MBRTOWC@
@@ -314,7 +624,7 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
314# endif 624# endif
315_GL_FUNCDECL_RPL (mbrtowc, size_t, 625_GL_FUNCDECL_RPL (mbrtowc, size_t,
316 (wchar_t *restrict pwc, const char *restrict s, size_t n, 626 (wchar_t *restrict pwc, const char *restrict s, size_t n,
317 mbstate_t *restrict ps)); 627 mbstate_t *restrict ps), );
318_GL_CXXALIAS_RPL (mbrtowc, size_t, 628_GL_CXXALIAS_RPL (mbrtowc, size_t,
319 (wchar_t *restrict pwc, const char *restrict s, size_t n, 629 (wchar_t *restrict pwc, const char *restrict s, size_t n,
320 mbstate_t *restrict ps)); 630 mbstate_t *restrict ps));
@@ -322,7 +632,7 @@ _GL_CXXALIAS_RPL (mbrtowc, size_t,
322# if !@HAVE_MBRTOWC@ 632# if !@HAVE_MBRTOWC@
323_GL_FUNCDECL_SYS (mbrtowc, size_t, 633_GL_FUNCDECL_SYS (mbrtowc, size_t,
324 (wchar_t *restrict pwc, const char *restrict s, size_t n, 634 (wchar_t *restrict pwc, const char *restrict s, size_t n,
325 mbstate_t *restrict ps)); 635 mbstate_t *restrict ps), );
326# endif 636# endif
327_GL_CXXALIAS_SYS (mbrtowc, size_t, 637_GL_CXXALIAS_SYS (mbrtowc, size_t,
328 (wchar_t *restrict pwc, const char *restrict s, size_t n, 638 (wchar_t *restrict pwc, const char *restrict s, size_t n,
@@ -348,13 +658,13 @@ _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
348# define mbrlen rpl_mbrlen 658# define mbrlen rpl_mbrlen
349# endif 659# endif
350_GL_FUNCDECL_RPL (mbrlen, size_t, 660_GL_FUNCDECL_RPL (mbrlen, size_t,
351 (const char *restrict s, size_t n, mbstate_t *restrict ps)); 661 (const char *restrict s, size_t n, mbstate_t *restrict ps), );
352_GL_CXXALIAS_RPL (mbrlen, size_t, 662_GL_CXXALIAS_RPL (mbrlen, size_t,
353 (const char *restrict s, size_t n, mbstate_t *restrict ps)); 663 (const char *restrict s, size_t n, mbstate_t *restrict ps));
354# else 664# else
355# if !@HAVE_MBRLEN@ 665# if !@HAVE_MBRLEN@
356_GL_FUNCDECL_SYS (mbrlen, size_t, 666_GL_FUNCDECL_SYS (mbrlen, size_t,
357 (const char *restrict s, size_t n, mbstate_t *restrict ps)); 667 (const char *restrict s, size_t n, mbstate_t *restrict ps), );
358# endif 668# endif
359_GL_CXXALIAS_SYS (mbrlen, size_t, 669_GL_CXXALIAS_SYS (mbrlen, size_t,
360 (const char *restrict s, size_t n, mbstate_t *restrict ps)); 670 (const char *restrict s, size_t n, mbstate_t *restrict ps));
@@ -381,7 +691,7 @@ _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
381_GL_FUNCDECL_RPL (mbsrtowcs, size_t, 691_GL_FUNCDECL_RPL (mbsrtowcs, size_t,
382 (wchar_t *restrict dest, 692 (wchar_t *restrict dest,
383 const char **restrict srcp, size_t len, 693 const char **restrict srcp, size_t len,
384 mbstate_t *restrict ps) 694 mbstate_t *restrict ps),
385 _GL_ARG_NONNULL ((2))); 695 _GL_ARG_NONNULL ((2)));
386_GL_CXXALIAS_RPL (mbsrtowcs, size_t, 696_GL_CXXALIAS_RPL (mbsrtowcs, size_t,
387 (wchar_t *restrict dest, 697 (wchar_t *restrict dest,
@@ -392,7 +702,7 @@ _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
392_GL_FUNCDECL_SYS (mbsrtowcs, size_t, 702_GL_FUNCDECL_SYS (mbsrtowcs, size_t,
393 (wchar_t *restrict dest, 703 (wchar_t *restrict dest,
394 const char **restrict srcp, size_t len, 704 const char **restrict srcp, size_t len,
395 mbstate_t *restrict ps) 705 mbstate_t *restrict ps),
396 _GL_ARG_NONNULL ((2))); 706 _GL_ARG_NONNULL ((2)));
397# endif 707# endif
398_GL_CXXALIAS_SYS (mbsrtowcs, size_t, 708_GL_CXXALIAS_SYS (mbsrtowcs, size_t,
@@ -422,7 +732,7 @@ _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
422_GL_FUNCDECL_RPL (mbsnrtowcs, size_t, 732_GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
423 (wchar_t *restrict dest, 733 (wchar_t *restrict dest,
424 const char **restrict srcp, size_t srclen, size_t len, 734 const char **restrict srcp, size_t srclen, size_t len,
425 mbstate_t *restrict ps) 735 mbstate_t *restrict ps),
426 _GL_ARG_NONNULL ((2))); 736 _GL_ARG_NONNULL ((2)));
427_GL_CXXALIAS_RPL (mbsnrtowcs, size_t, 737_GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
428 (wchar_t *restrict dest, 738 (wchar_t *restrict dest,
@@ -433,7 +743,7 @@ _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
433_GL_FUNCDECL_SYS (mbsnrtowcs, size_t, 743_GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
434 (wchar_t *restrict dest, 744 (wchar_t *restrict dest,
435 const char **restrict srcp, size_t srclen, size_t len, 745 const char **restrict srcp, size_t srclen, size_t len,
436 mbstate_t *restrict ps) 746 mbstate_t *restrict ps),
437 _GL_ARG_NONNULL ((2))); 747 _GL_ARG_NONNULL ((2)));
438# endif 748# endif
439_GL_CXXALIAS_SYS (mbsnrtowcs, size_t, 749_GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
@@ -441,7 +751,9 @@ _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
441 const char **restrict srcp, size_t srclen, size_t len, 751 const char **restrict srcp, size_t srclen, size_t len,
442 mbstate_t *restrict ps)); 752 mbstate_t *restrict ps));
443# endif 753# endif
754# if __GLIBC__ >= 2
444_GL_CXXALIASWARN (mbsnrtowcs); 755_GL_CXXALIASWARN (mbsnrtowcs);
756# endif
445#elif defined GNULIB_POSIXCHECK 757#elif defined GNULIB_POSIXCHECK
446# undef mbsnrtowcs 758# undef mbsnrtowcs
447# if HAVE_RAW_DECL_MBSNRTOWCS 759# if HAVE_RAW_DECL_MBSNRTOWCS
@@ -459,13 +771,13 @@ _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
459# define wcrtomb rpl_wcrtomb 771# define wcrtomb rpl_wcrtomb
460# endif 772# endif
461_GL_FUNCDECL_RPL (wcrtomb, size_t, 773_GL_FUNCDECL_RPL (wcrtomb, size_t,
462 (char *restrict s, wchar_t wc, mbstate_t *restrict ps)); 774 (char *restrict s, wchar_t wc, mbstate_t *restrict ps), );
463_GL_CXXALIAS_RPL (wcrtomb, size_t, 775_GL_CXXALIAS_RPL (wcrtomb, size_t,
464 (char *restrict s, wchar_t wc, mbstate_t *restrict ps)); 776 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
465# else 777# else
466# if !@HAVE_WCRTOMB@ 778# if !@HAVE_WCRTOMB@
467_GL_FUNCDECL_SYS (wcrtomb, size_t, 779_GL_FUNCDECL_SYS (wcrtomb, size_t,
468 (char *restrict s, wchar_t wc, mbstate_t *restrict ps)); 780 (char *restrict s, wchar_t wc, mbstate_t *restrict ps), );
469# endif 781# endif
470_GL_CXXALIAS_SYS (wcrtomb, size_t, 782_GL_CXXALIAS_SYS (wcrtomb, size_t,
471 (char *restrict s, wchar_t wc, mbstate_t *restrict ps)); 783 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
@@ -492,7 +804,7 @@ _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
492_GL_FUNCDECL_RPL (wcsrtombs, size_t, 804_GL_FUNCDECL_RPL (wcsrtombs, size_t,
493 (char *restrict dest, const wchar_t **restrict srcp, 805 (char *restrict dest, const wchar_t **restrict srcp,
494 size_t len, 806 size_t len,
495 mbstate_t *restrict ps) 807 mbstate_t *restrict ps),
496 _GL_ARG_NONNULL ((2))); 808 _GL_ARG_NONNULL ((2)));
497_GL_CXXALIAS_RPL (wcsrtombs, size_t, 809_GL_CXXALIAS_RPL (wcsrtombs, size_t,
498 (char *restrict dest, const wchar_t **restrict srcp, 810 (char *restrict dest, const wchar_t **restrict srcp,
@@ -503,7 +815,7 @@ _GL_CXXALIAS_RPL (wcsrtombs, size_t,
503_GL_FUNCDECL_SYS (wcsrtombs, size_t, 815_GL_FUNCDECL_SYS (wcsrtombs, size_t,
504 (char *restrict dest, const wchar_t **restrict srcp, 816 (char *restrict dest, const wchar_t **restrict srcp,
505 size_t len, 817 size_t len,
506 mbstate_t *restrict ps) 818 mbstate_t *restrict ps),
507 _GL_ARG_NONNULL ((2))); 819 _GL_ARG_NONNULL ((2)));
508# endif 820# endif
509_GL_CXXALIAS_SYS (wcsrtombs, size_t, 821_GL_CXXALIAS_SYS (wcsrtombs, size_t,
@@ -534,7 +846,7 @@ _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
534 (char *restrict dest, 846 (char *restrict dest,
535 const wchar_t **restrict srcp, size_t srclen, 847 const wchar_t **restrict srcp, size_t srclen,
536 size_t len, 848 size_t len,
537 mbstate_t *restrict ps) 849 mbstate_t *restrict ps),
538 _GL_ARG_NONNULL ((2))); 850 _GL_ARG_NONNULL ((2)));
539_GL_CXXALIAS_RPL (wcsnrtombs, size_t, 851_GL_CXXALIAS_RPL (wcsnrtombs, size_t,
540 (char *restrict dest, 852 (char *restrict dest,
@@ -547,7 +859,7 @@ _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
547 (char *restrict dest, 859 (char *restrict dest,
548 const wchar_t **restrict srcp, size_t srclen, 860 const wchar_t **restrict srcp, size_t srclen,
549 size_t len, 861 size_t len,
550 mbstate_t *restrict ps) 862 mbstate_t *restrict ps),
551 _GL_ARG_NONNULL ((2))); 863 _GL_ARG_NONNULL ((2)));
552# endif 864# endif
553_GL_CXXALIAS_SYS (wcsnrtombs, size_t, 865_GL_CXXALIAS_SYS (wcsnrtombs, size_t,
@@ -575,12 +887,12 @@ _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
575# undef wcwidth 887# undef wcwidth
576# define wcwidth rpl_wcwidth 888# define wcwidth rpl_wcwidth
577# endif 889# endif
578_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); 890_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t), _GL_ATTRIBUTE_PURE);
579_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t)); 891_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
580# else 892# else
581# if !@HAVE_DECL_WCWIDTH@ 893# if !@HAVE_DECL_WCWIDTH@
582/* wcwidth exists but is not declared. */ 894/* wcwidth exists but is not declared. */
583_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); 895_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t), _GL_ATTRIBUTE_PURE);
584# endif 896# endif
585_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t)); 897_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
586# endif 898# endif
@@ -599,8 +911,9 @@ _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
599/* Search N wide characters of S for C. */ 911/* Search N wide characters of S for C. */
600#if @GNULIB_WMEMCHR@ 912#if @GNULIB_WMEMCHR@
601# if !@HAVE_WMEMCHR@ 913# if !@HAVE_WMEMCHR@
602_GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n) 914_GL_FUNCDECL_SYS (wmemchr, wchar_t *,
603 _GL_ATTRIBUTE_PURE); 915 (const wchar_t *s, wchar_t c, size_t n),
916 _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
604# endif 917# endif
605 /* On some systems, this function is defined as an overloaded function: 918 /* On some systems, this function is defined as an overloaded function:
606 extern "C++" { 919 extern "C++" {
@@ -611,11 +924,12 @@ _GL_CXXALIAS_SYS_CAST2 (wmemchr,
611 wchar_t *, (const wchar_t *, wchar_t, size_t), 924 wchar_t *, (const wchar_t *, wchar_t, size_t),
612 const wchar_t *, (const wchar_t *, wchar_t, size_t)); 925 const wchar_t *, (const wchar_t *, wchar_t, size_t));
613# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 926# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
614 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 927 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
928 && !defined __clang__
615_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 929_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
616_GL_CXXALIASWARN1 (wmemchr, const wchar_t *, 930_GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
617 (const wchar_t *s, wchar_t c, size_t n)); 931 (const wchar_t *s, wchar_t c, size_t n));
618# elif __GLIBC__ >= 2 932# elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
619_GL_CXXALIASWARN (wmemchr); 933_GL_CXXALIASWARN (wmemchr);
620# endif 934# endif
621#elif defined GNULIB_POSIXCHECK 935#elif defined GNULIB_POSIXCHECK
@@ -629,13 +943,29 @@ _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
629 943
630/* Compare N wide characters of S1 and S2. */ 944/* Compare N wide characters of S1 and S2. */
631#if @GNULIB_WMEMCMP@ 945#if @GNULIB_WMEMCMP@
632# if !@HAVE_WMEMCMP@ 946# if @REPLACE_WMEMCMP@
947# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
948# undef wmemcmp
949# define wmemcmp rpl_wmemcmp
950# endif
951_GL_FUNCDECL_RPL (wmemcmp, int,
952 (const wchar_t *s1, const wchar_t *s2, size_t n),
953 _GL_ATTRIBUTE_PURE
954 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
955 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
956_GL_CXXALIAS_RPL (wmemcmp, int,
957 (const wchar_t *s1, const wchar_t *s2, size_t n));
958# else
959# if !@HAVE_WMEMCMP@
633_GL_FUNCDECL_SYS (wmemcmp, int, 960_GL_FUNCDECL_SYS (wmemcmp, int,
634 (const wchar_t *s1, const wchar_t *s2, size_t n) 961 (const wchar_t *s1, const wchar_t *s2, size_t n),
635 _GL_ATTRIBUTE_PURE); 962 _GL_ATTRIBUTE_PURE
636# endif 963 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
964 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
965# endif
637_GL_CXXALIAS_SYS (wmemcmp, int, 966_GL_CXXALIAS_SYS (wmemcmp, int,
638 (const wchar_t *s1, const wchar_t *s2, size_t n)); 967 (const wchar_t *s1, const wchar_t *s2, size_t n));
968# endif
639# if __GLIBC__ >= 2 969# if __GLIBC__ >= 2
640_GL_CXXALIASWARN (wmemcmp); 970_GL_CXXALIASWARN (wmemcmp);
641# endif 971# endif
@@ -653,7 +983,9 @@ _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
653# if !@HAVE_WMEMCPY@ 983# if !@HAVE_WMEMCPY@
654_GL_FUNCDECL_SYS (wmemcpy, wchar_t *, 984_GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
655 (wchar_t *restrict dest, 985 (wchar_t *restrict dest,
656 const wchar_t *restrict src, size_t n)); 986 const wchar_t *restrict src, size_t n),
987 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
988 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
657# endif 989# endif
658_GL_CXXALIAS_SYS (wmemcpy, wchar_t *, 990_GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
659 (wchar_t *restrict dest, 991 (wchar_t *restrict dest,
@@ -675,7 +1007,9 @@ _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
675#if @GNULIB_WMEMMOVE@ 1007#if @GNULIB_WMEMMOVE@
676# if !@HAVE_WMEMMOVE@ 1008# if !@HAVE_WMEMMOVE@
677_GL_FUNCDECL_SYS (wmemmove, wchar_t *, 1009_GL_FUNCDECL_SYS (wmemmove, wchar_t *,
678 (wchar_t *dest, const wchar_t *src, size_t n)); 1010 (wchar_t *dest, const wchar_t *src, size_t n),
1011 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1012 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
679# endif 1013# endif
680_GL_CXXALIAS_SYS (wmemmove, wchar_t *, 1014_GL_CXXALIAS_SYS (wmemmove, wchar_t *,
681 (wchar_t *dest, const wchar_t *src, size_t n)); 1015 (wchar_t *dest, const wchar_t *src, size_t n));
@@ -694,14 +1028,27 @@ _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
694/* Copy N wide characters of SRC to DEST. 1028/* Copy N wide characters of SRC to DEST.
695 Return pointer to wide characters after the last written wide character. */ 1029 Return pointer to wide characters after the last written wide character. */
696#if @GNULIB_WMEMPCPY@ 1030#if @GNULIB_WMEMPCPY@
697# if !@HAVE_WMEMPCPY@ 1031# if @REPLACE_WMEMPCPY@
698_GL_FUNCDECL_SYS (wmempcpy, wchar_t *, 1032# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1033# undef wmempcpy
1034# define wmempcpy rpl_wmempcpy
1035# endif
1036_GL_FUNCDECL_RPL (wmempcpy, wchar_t *,
1037 (wchar_t *restrict dest,
1038 const wchar_t *restrict src, size_t n), );
1039_GL_CXXALIAS_RPL (wmempcpy, wchar_t *,
699 (wchar_t *restrict dest, 1040 (wchar_t *restrict dest,
700 const wchar_t *restrict src, size_t n)); 1041 const wchar_t *restrict src, size_t n));
701# endif 1042# else
1043# if !@HAVE_WMEMPCPY@
1044_GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
1045 (wchar_t *restrict dest,
1046 const wchar_t *restrict src, size_t n), );
1047# endif
702_GL_CXXALIAS_SYS (wmempcpy, wchar_t *, 1048_GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
703 (wchar_t *restrict dest, 1049 (wchar_t *restrict dest,
704 const wchar_t *restrict src, size_t n)); 1050 const wchar_t *restrict src, size_t n));
1051# endif
705# if __GLIBC__ >= 2 1052# if __GLIBC__ >= 2
706_GL_CXXALIASWARN (wmempcpy); 1053_GL_CXXALIASWARN (wmempcpy);
707# endif 1054# endif
@@ -717,7 +1064,8 @@ _GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
717/* Set N wide characters of S to C. */ 1064/* Set N wide characters of S to C. */
718#if @GNULIB_WMEMSET@ 1065#if @GNULIB_WMEMSET@
719# if !@HAVE_WMEMSET@ 1066# if !@HAVE_WMEMSET@
720_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 1067_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n),
1068 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
721# endif 1069# endif
722_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 1070_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
723# if __GLIBC__ >= 2 1071# if __GLIBC__ >= 2
@@ -735,7 +1083,7 @@ _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
735/* Return the number of wide characters in S. */ 1083/* Return the number of wide characters in S. */
736#if @GNULIB_WCSLEN@ 1084#if @GNULIB_WCSLEN@
737# if !@HAVE_WCSLEN@ 1085# if !@HAVE_WCSLEN@
738_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE); 1086_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s), _GL_ATTRIBUTE_PURE);
739# endif 1087# endif
740_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s)); 1088_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
741# if __GLIBC__ >= 2 1089# if __GLIBC__ >= 2
@@ -756,7 +1104,7 @@ _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
756 namespace, not in the global namespace. So, force a declaration in 1104 namespace, not in the global namespace. So, force a declaration in
757 the global namespace. */ 1105 the global namespace. */
758# if !@HAVE_WCSNLEN@ || (defined __sun && defined __cplusplus) 1106# if !@HAVE_WCSNLEN@ || (defined __sun && defined __cplusplus)
759_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen) 1107_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen),
760 _GL_ATTRIBUTE_PURE); 1108 _GL_ATTRIBUTE_PURE);
761# endif 1109# endif
762_GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)); 1110_GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
@@ -774,7 +1122,7 @@ _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
774#if @GNULIB_WCSCPY@ 1122#if @GNULIB_WCSCPY@
775# if !@HAVE_WCSCPY@ 1123# if !@HAVE_WCSCPY@
776_GL_FUNCDECL_SYS (wcscpy, wchar_t *, 1124_GL_FUNCDECL_SYS (wcscpy, wchar_t *,
777 (wchar_t *restrict dest, const wchar_t *restrict src)); 1125 (wchar_t *restrict dest, const wchar_t *restrict src), );
778# endif 1126# endif
779_GL_CXXALIAS_SYS (wcscpy, wchar_t *, 1127_GL_CXXALIAS_SYS (wcscpy, wchar_t *,
780 (wchar_t *restrict dest, const wchar_t *restrict src)); 1128 (wchar_t *restrict dest, const wchar_t *restrict src));
@@ -797,7 +1145,7 @@ _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
797 the global namespace. */ 1145 the global namespace. */
798# if !@HAVE_WCPCPY@ || (defined __sun && defined __cplusplus) 1146# if !@HAVE_WCPCPY@ || (defined __sun && defined __cplusplus)
799_GL_FUNCDECL_SYS (wcpcpy, wchar_t *, 1147_GL_FUNCDECL_SYS (wcpcpy, wchar_t *,
800 (wchar_t *restrict dest, const wchar_t *restrict src)); 1148 (wchar_t *restrict dest, const wchar_t *restrict src), );
801# endif 1149# endif
802_GL_CXXALIAS_SYS (wcpcpy, wchar_t *, 1150_GL_CXXALIAS_SYS (wcpcpy, wchar_t *,
803 (wchar_t *restrict dest, const wchar_t *restrict src)); 1151 (wchar_t *restrict dest, const wchar_t *restrict src));
@@ -816,7 +1164,9 @@ _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
816# if !@HAVE_WCSNCPY@ 1164# if !@HAVE_WCSNCPY@
817_GL_FUNCDECL_SYS (wcsncpy, wchar_t *, 1165_GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
818 (wchar_t *restrict dest, 1166 (wchar_t *restrict dest,
819 const wchar_t *restrict src, size_t n)); 1167 const wchar_t *restrict src, size_t n),
1168 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1169 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
820# endif 1170# endif
821_GL_CXXALIAS_SYS (wcsncpy, wchar_t *, 1171_GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
822 (wchar_t *restrict dest, 1172 (wchar_t *restrict dest,
@@ -842,7 +1192,7 @@ _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
842# if !@HAVE_WCPNCPY@ || (defined __sun && defined __cplusplus) 1192# if !@HAVE_WCPNCPY@ || (defined __sun && defined __cplusplus)
843_GL_FUNCDECL_SYS (wcpncpy, wchar_t *, 1193_GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
844 (wchar_t *restrict dest, 1194 (wchar_t *restrict dest,
845 const wchar_t *restrict src, size_t n)); 1195 const wchar_t *restrict src, size_t n), );
846# endif 1196# endif
847_GL_CXXALIAS_SYS (wcpncpy, wchar_t *, 1197_GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
848 (wchar_t *restrict dest, 1198 (wchar_t *restrict dest,
@@ -861,7 +1211,7 @@ _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
861#if @GNULIB_WCSCAT@ 1211#if @GNULIB_WCSCAT@
862# if !@HAVE_WCSCAT@ 1212# if !@HAVE_WCSCAT@
863_GL_FUNCDECL_SYS (wcscat, wchar_t *, 1213_GL_FUNCDECL_SYS (wcscat, wchar_t *,
864 (wchar_t *restrict dest, const wchar_t *restrict src)); 1214 (wchar_t *restrict dest, const wchar_t *restrict src), );
865# endif 1215# endif
866_GL_CXXALIAS_SYS (wcscat, wchar_t *, 1216_GL_CXXALIAS_SYS (wcscat, wchar_t *,
867 (wchar_t *restrict dest, const wchar_t *restrict src)); 1217 (wchar_t *restrict dest, const wchar_t *restrict src));
@@ -879,14 +1229,31 @@ _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
879 1229
880/* Append no more than N wide characters of SRC onto DEST. */ 1230/* Append no more than N wide characters of SRC onto DEST. */
881#if @GNULIB_WCSNCAT@ 1231#if @GNULIB_WCSNCAT@
882# if !@HAVE_WCSNCAT@ 1232# if @REPLACE_WCSNCAT@
883_GL_FUNCDECL_SYS (wcsncat, wchar_t *, 1233# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1234# undef wcsncat
1235# define wcsncat rpl_wcsncat
1236# endif
1237_GL_FUNCDECL_RPL (wcsncat, wchar_t *,
1238 (wchar_t *restrict dest, const wchar_t *restrict src,
1239 size_t n),
1240 _GL_ARG_NONNULL ((1))
1241 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1242_GL_CXXALIAS_RPL (wcsncat, wchar_t *,
884 (wchar_t *restrict dest, const wchar_t *restrict src, 1243 (wchar_t *restrict dest, const wchar_t *restrict src,
885 size_t n)); 1244 size_t n));
886# endif 1245# else
1246# if !@HAVE_WCSNCAT@
1247_GL_FUNCDECL_SYS (wcsncat, wchar_t *,
1248 (wchar_t *restrict dest, const wchar_t *restrict src,
1249 size_t n),
1250 _GL_ARG_NONNULL ((1))
1251 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1252# endif
887_GL_CXXALIAS_SYS (wcsncat, wchar_t *, 1253_GL_CXXALIAS_SYS (wcsncat, wchar_t *,
888 (wchar_t *restrict dest, const wchar_t *restrict src, 1254 (wchar_t *restrict dest, const wchar_t *restrict src,
889 size_t n)); 1255 size_t n));
1256# endif
890# if __GLIBC__ >= 2 1257# if __GLIBC__ >= 2
891_GL_CXXALIASWARN (wcsncat); 1258_GL_CXXALIASWARN (wcsncat);
892# endif 1259# endif
@@ -901,11 +1268,21 @@ _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
901 1268
902/* Compare S1 and S2. */ 1269/* Compare S1 and S2. */
903#if @GNULIB_WCSCMP@ 1270#if @GNULIB_WCSCMP@
904# if !@HAVE_WCSCMP@ 1271# if @REPLACE_WCSCMP@
905_GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2) 1272# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1273# undef wcscmp
1274# define wcscmp rpl_wcscmp
1275# endif
1276_GL_FUNCDECL_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2),
906 _GL_ATTRIBUTE_PURE); 1277 _GL_ATTRIBUTE_PURE);
907# endif 1278_GL_CXXALIAS_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
1279# else
1280# if !@HAVE_WCSCMP@
1281_GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2),
1282 _GL_ATTRIBUTE_PURE);
1283# endif
908_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); 1284_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
1285# endif
909# if __GLIBC__ >= 2 1286# if __GLIBC__ >= 2
910_GL_CXXALIASWARN (wcscmp); 1287_GL_CXXALIASWARN (wcscmp);
911# endif 1288# endif
@@ -920,13 +1297,29 @@ _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
920 1297
921/* Compare no more than N wide characters of S1 and S2. */ 1298/* Compare no more than N wide characters of S1 and S2. */
922#if @GNULIB_WCSNCMP@ 1299#if @GNULIB_WCSNCMP@
923# if !@HAVE_WCSNCMP@ 1300# if @REPLACE_WCSNCMP@
1301# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1302# undef wcsncmp
1303# define wcsncmp rpl_wcsncmp
1304# endif
1305_GL_FUNCDECL_RPL (wcsncmp, int,
1306 (const wchar_t *s1, const wchar_t *s2, size_t n),
1307 _GL_ATTRIBUTE_PURE
1308 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1309 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1310_GL_CXXALIAS_RPL (wcsncmp, int,
1311 (const wchar_t *s1, const wchar_t *s2, size_t n));
1312# else
1313# if !@HAVE_WCSNCMP@
924_GL_FUNCDECL_SYS (wcsncmp, int, 1314_GL_FUNCDECL_SYS (wcsncmp, int,
925 (const wchar_t *s1, const wchar_t *s2, size_t n) 1315 (const wchar_t *s1, const wchar_t *s2, size_t n),
926 _GL_ATTRIBUTE_PURE); 1316 _GL_ATTRIBUTE_PURE
927# endif 1317 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1318 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1319# endif
928_GL_CXXALIAS_SYS (wcsncmp, int, 1320_GL_CXXALIAS_SYS (wcsncmp, int,
929 (const wchar_t *s1, const wchar_t *s2, size_t n)); 1321 (const wchar_t *s1, const wchar_t *s2, size_t n));
1322# endif
930# if __GLIBC__ >= 2 1323# if __GLIBC__ >= 2
931_GL_CXXALIASWARN (wcsncmp); 1324_GL_CXXALIASWARN (wcsncmp);
932# endif 1325# endif
@@ -945,7 +1338,7 @@ _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
945 namespace, not in the global namespace. So, force a declaration in 1338 namespace, not in the global namespace. So, force a declaration in
946 the global namespace. */ 1339 the global namespace. */
947# if !@HAVE_WCSCASECMP@ || (defined __sun && defined __cplusplus) 1340# if !@HAVE_WCSCASECMP@ || (defined __sun && defined __cplusplus)
948_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2) 1341_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2),
949 _GL_ATTRIBUTE_PURE); 1342 _GL_ATTRIBUTE_PURE);
950# endif 1343# endif
951_GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)); 1344_GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
@@ -966,7 +1359,7 @@ _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
966 the global namespace. */ 1359 the global namespace. */
967# if !@HAVE_WCSNCASECMP@ || (defined __sun && defined __cplusplus) 1360# if !@HAVE_WCSNCASECMP@ || (defined __sun && defined __cplusplus)
968_GL_FUNCDECL_SYS (wcsncasecmp, int, 1361_GL_FUNCDECL_SYS (wcsncasecmp, int,
969 (const wchar_t *s1, const wchar_t *s2, size_t n) 1362 (const wchar_t *s1, const wchar_t *s2, size_t n),
970 _GL_ATTRIBUTE_PURE); 1363 _GL_ATTRIBUTE_PURE);
971# endif 1364# endif
972_GL_CXXALIAS_SYS (wcsncasecmp, int, 1365_GL_CXXALIAS_SYS (wcsncasecmp, int,
@@ -985,7 +1378,7 @@ _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
985 category of the current locale. */ 1378 category of the current locale. */
986#if @GNULIB_WCSCOLL@ 1379#if @GNULIB_WCSCOLL@
987# if !@HAVE_WCSCOLL@ 1380# if !@HAVE_WCSCOLL@
988_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); 1381_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2), );
989# endif 1382# endif
990_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); 1383_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
991# if __GLIBC__ >= 2 1384# if __GLIBC__ >= 2
@@ -1006,7 +1399,7 @@ _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
1006#if @GNULIB_WCSXFRM@ 1399#if @GNULIB_WCSXFRM@
1007# if !@HAVE_WCSXFRM@ 1400# if !@HAVE_WCSXFRM@
1008_GL_FUNCDECL_SYS (wcsxfrm, size_t, 1401_GL_FUNCDECL_SYS (wcsxfrm, size_t,
1009 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n)); 1402 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n), );
1010# endif 1403# endif
1011_GL_CXXALIAS_SYS (wcsxfrm, size_t, 1404_GL_CXXALIAS_SYS (wcsxfrm, size_t,
1012 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n)); 1405 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
@@ -1034,20 +1427,35 @@ _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1034/* On Solaris 11.3, the header files declare the function in the std:: 1427/* On Solaris 11.3, the header files declare the function in the std::
1035 namespace, not in the global namespace. So, force a declaration in 1428 namespace, not in the global namespace. So, force a declaration in
1036 the global namespace. */ 1429 the global namespace. */
1037# if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11 1430# if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) \
1431 || (__GNUC__ >= 11 && !defined __clang__)
1432# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1038_GL_FUNCDECL_SYS (wcsdup, wchar_t *, 1433_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1039 (const wchar_t *s) 1434 (const wchar_t *s),
1435 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1436 _GL_ATTRIBUTE_NOTHROW;
1437# else
1438_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1439 (const wchar_t *s),
1040 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 1440 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1441# endif
1041# endif 1442# endif
1042_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); 1443_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1043# endif 1444# endif
1044_GL_CXXALIASWARN (wcsdup); 1445_GL_CXXALIASWARN (wcsdup);
1045#else 1446#else
1046# if __GNUC__ >= 11 && !defined wcsdup 1447# if (__GNUC__ >= 11 && !defined __clang__) && !defined wcsdup
1047/* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */ 1448/* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */
1449# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1450_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1451 (const wchar_t *s),
1452 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1453 _GL_ATTRIBUTE_NOTHROW;
1454# else
1048_GL_FUNCDECL_SYS (wcsdup, wchar_t *, 1455_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1049 (const wchar_t *s) 1456 (const wchar_t *s),
1050 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 1457 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1458# endif
1051# endif 1459# endif
1052# if defined GNULIB_POSIXCHECK 1460# if defined GNULIB_POSIXCHECK
1053# undef wcsdup 1461# undef wcsdup
@@ -1066,9 +1474,16 @@ _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
1066# endif 1474# endif
1067_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s)); 1475_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1068# else 1476# else
1477# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1478_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1479 (const wchar_t *s),
1480 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1481 _GL_ATTRIBUTE_NOTHROW;
1482# else
1069_GL_FUNCDECL_SYS (wcsdup, wchar_t *, 1483_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1070 (const wchar_t *s) 1484 (const wchar_t *s),
1071 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 1485 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1486# endif
1072# if @HAVE_DECL_WCSDUP@ 1487# if @HAVE_DECL_WCSDUP@
1073_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); 1488_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1074# endif 1489# endif
@@ -1083,7 +1498,7 @@ _GL_CXXALIASWARN (wcsdup);
1083/* Find the first occurrence of WC in WCS. */ 1498/* Find the first occurrence of WC in WCS. */
1084#if @GNULIB_WCSCHR@ 1499#if @GNULIB_WCSCHR@
1085# if !@HAVE_WCSCHR@ 1500# if !@HAVE_WCSCHR@
1086_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc) 1501_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc),
1087 _GL_ATTRIBUTE_PURE); 1502 _GL_ATTRIBUTE_PURE);
1088# endif 1503# endif
1089 /* On some systems, this function is defined as an overloaded function: 1504 /* On some systems, this function is defined as an overloaded function:
@@ -1095,10 +1510,11 @@ _GL_CXXALIAS_SYS_CAST2 (wcschr,
1095 wchar_t *, (const wchar_t *, wchar_t), 1510 wchar_t *, (const wchar_t *, wchar_t),
1096 const wchar_t *, (const wchar_t *, wchar_t)); 1511 const wchar_t *, (const wchar_t *, wchar_t));
1097# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1512# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1098 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1513 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1514 && !defined __clang__
1099_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc)); 1515_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
1100_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); 1516_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
1101# elif __GLIBC__ >= 2 1517# elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1102_GL_CXXALIASWARN (wcschr); 1518_GL_CXXALIASWARN (wcschr);
1103# endif 1519# endif
1104#elif defined GNULIB_POSIXCHECK 1520#elif defined GNULIB_POSIXCHECK
@@ -1113,7 +1529,7 @@ _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
1113/* Find the last occurrence of WC in WCS. */ 1529/* Find the last occurrence of WC in WCS. */
1114#if @GNULIB_WCSRCHR@ 1530#if @GNULIB_WCSRCHR@
1115# if !@HAVE_WCSRCHR@ 1531# if !@HAVE_WCSRCHR@
1116_GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc) 1532_GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc),
1117 _GL_ATTRIBUTE_PURE); 1533 _GL_ATTRIBUTE_PURE);
1118# endif 1534# endif
1119 /* On some systems, this function is defined as an overloaded function: 1535 /* On some systems, this function is defined as an overloaded function:
@@ -1125,10 +1541,11 @@ _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
1125 wchar_t *, (const wchar_t *, wchar_t), 1541 wchar_t *, (const wchar_t *, wchar_t),
1126 const wchar_t *, (const wchar_t *, wchar_t)); 1542 const wchar_t *, (const wchar_t *, wchar_t));
1127# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1543# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1128 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1544 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1545 && !defined __clang__
1129_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc)); 1546_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
1130_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); 1547_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
1131# elif __GLIBC__ >= 2 1548# elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1132_GL_CXXALIASWARN (wcsrchr); 1549_GL_CXXALIASWARN (wcsrchr);
1133# endif 1550# endif
1134#elif defined GNULIB_POSIXCHECK 1551#elif defined GNULIB_POSIXCHECK
@@ -1140,11 +1557,11 @@ _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
1140#endif 1557#endif
1141 1558
1142 1559
1143/* Return the length of the initial segmet of WCS which consists entirely 1560/* Return the length of the initial segment of WCS which consists entirely
1144 of wide characters not in REJECT. */ 1561 of wide characters not in REJECT. */
1145#if @GNULIB_WCSCSPN@ 1562#if @GNULIB_WCSCSPN@
1146# if !@HAVE_WCSCSPN@ 1563# if !@HAVE_WCSCSPN@
1147_GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject) 1564_GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject),
1148 _GL_ATTRIBUTE_PURE); 1565 _GL_ATTRIBUTE_PURE);
1149# endif 1566# endif
1150_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)); 1567_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
@@ -1160,11 +1577,11 @@ _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
1160#endif 1577#endif
1161 1578
1162 1579
1163/* Return the length of the initial segmet of WCS which consists entirely 1580/* Return the length of the initial segment of WCS which consists entirely
1164 of wide characters in ACCEPT. */ 1581 of wide characters in ACCEPT. */
1165#if @GNULIB_WCSSPN@ 1582#if @GNULIB_WCSSPN@
1166# if !@HAVE_WCSSPN@ 1583# if !@HAVE_WCSSPN@
1167_GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept) 1584_GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept),
1168 _GL_ATTRIBUTE_PURE); 1585 _GL_ATTRIBUTE_PURE);
1169# endif 1586# endif
1170_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)); 1587_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
@@ -1184,7 +1601,7 @@ _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
1184#if @GNULIB_WCSPBRK@ 1601#if @GNULIB_WCSPBRK@
1185# if !@HAVE_WCSPBRK@ 1602# if !@HAVE_WCSPBRK@
1186_GL_FUNCDECL_SYS (wcspbrk, wchar_t *, 1603_GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
1187 (const wchar_t *wcs, const wchar_t *accept) 1604 (const wchar_t *wcs, const wchar_t *accept),
1188 _GL_ATTRIBUTE_PURE); 1605 _GL_ATTRIBUTE_PURE);
1189# endif 1606# endif
1190 /* On some systems, this function is defined as an overloaded function: 1607 /* On some systems, this function is defined as an overloaded function:
@@ -1196,12 +1613,13 @@ _GL_CXXALIAS_SYS_CAST2 (wcspbrk,
1196 wchar_t *, (const wchar_t *, const wchar_t *), 1613 wchar_t *, (const wchar_t *, const wchar_t *),
1197 const wchar_t *, (const wchar_t *, const wchar_t *)); 1614 const wchar_t *, (const wchar_t *, const wchar_t *));
1198# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1615# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1199 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1616 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1617 && !defined __clang__
1200_GL_CXXALIASWARN1 (wcspbrk, wchar_t *, 1618_GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
1201 (wchar_t *wcs, const wchar_t *accept)); 1619 (wchar_t *wcs, const wchar_t *accept));
1202_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *, 1620_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
1203 (const wchar_t *wcs, const wchar_t *accept)); 1621 (const wchar_t *wcs, const wchar_t *accept));
1204# elif __GLIBC__ >= 2 1622# elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1205_GL_CXXALIASWARN (wcspbrk); 1623_GL_CXXALIASWARN (wcspbrk);
1206# endif 1624# endif
1207#elif defined GNULIB_POSIXCHECK 1625#elif defined GNULIB_POSIXCHECK
@@ -1215,12 +1633,25 @@ _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
1215 1633
1216/* Find the first occurrence of NEEDLE in HAYSTACK. */ 1634/* Find the first occurrence of NEEDLE in HAYSTACK. */
1217#if @GNULIB_WCSSTR@ 1635#if @GNULIB_WCSSTR@
1218# if !@HAVE_WCSSTR@ 1636# if @REPLACE_WCSSTR@
1637# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1638# undef wcsstr
1639# define wcsstr rpl_wcsstr
1640# endif
1641_GL_FUNCDECL_RPL (wcsstr, wchar_t *,
1642 (const wchar_t *restrict haystack,
1643 const wchar_t *restrict needle),
1644 _GL_ATTRIBUTE_PURE);
1645_GL_CXXALIAS_RPL (wcsstr, wchar_t *,
1646 (const wchar_t *restrict haystack,
1647 const wchar_t *restrict needle));
1648# else
1649# if !@HAVE_WCSSTR@
1219_GL_FUNCDECL_SYS (wcsstr, wchar_t *, 1650_GL_FUNCDECL_SYS (wcsstr, wchar_t *,
1220 (const wchar_t *restrict haystack, 1651 (const wchar_t *restrict haystack,
1221 const wchar_t *restrict needle) 1652 const wchar_t *restrict needle),
1222 _GL_ATTRIBUTE_PURE); 1653 _GL_ATTRIBUTE_PURE);
1223# endif 1654# endif
1224 /* On some systems, this function is defined as an overloaded function: 1655 /* On some systems, this function is defined as an overloaded function:
1225 extern "C++" { 1656 extern "C++" {
1226 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *); 1657 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
@@ -1231,15 +1662,17 @@ _GL_CXXALIAS_SYS_CAST2 (wcsstr,
1231 (const wchar_t *restrict, const wchar_t *restrict), 1662 (const wchar_t *restrict, const wchar_t *restrict),
1232 const wchar_t *, 1663 const wchar_t *,
1233 (const wchar_t *restrict, const wchar_t *restrict)); 1664 (const wchar_t *restrict, const wchar_t *restrict));
1665# endif
1234# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1666# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1235 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1667 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1668 && !defined __clang__
1236_GL_CXXALIASWARN1 (wcsstr, wchar_t *, 1669_GL_CXXALIASWARN1 (wcsstr, wchar_t *,
1237 (wchar_t *restrict haystack, 1670 (wchar_t *restrict haystack,
1238 const wchar_t *restrict needle)); 1671 const wchar_t *restrict needle));
1239_GL_CXXALIASWARN1 (wcsstr, const wchar_t *, 1672_GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
1240 (const wchar_t *restrict haystack, 1673 (const wchar_t *restrict haystack,
1241 const wchar_t *restrict needle)); 1674 const wchar_t *restrict needle));
1242# elif __GLIBC__ >= 2 1675# elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1243_GL_CXXALIASWARN (wcsstr); 1676_GL_CXXALIASWARN (wcsstr);
1244# endif 1677# endif
1245#elif defined GNULIB_POSIXCHECK 1678#elif defined GNULIB_POSIXCHECK
@@ -1260,7 +1693,7 @@ _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
1260# endif 1693# endif
1261_GL_FUNCDECL_RPL (wcstok, wchar_t *, 1694_GL_FUNCDECL_RPL (wcstok, wchar_t *,
1262 (wchar_t *restrict wcs, const wchar_t *restrict delim, 1695 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1263 wchar_t **restrict ptr)); 1696 wchar_t **restrict ptr), );
1264_GL_CXXALIAS_RPL (wcstok, wchar_t *, 1697_GL_CXXALIAS_RPL (wcstok, wchar_t *,
1265 (wchar_t *restrict wcs, const wchar_t *restrict delim, 1698 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1266 wchar_t **restrict ptr)); 1699 wchar_t **restrict ptr));
@@ -1268,7 +1701,7 @@ _GL_CXXALIAS_RPL (wcstok, wchar_t *,
1268# if !@HAVE_WCSTOK@ 1701# if !@HAVE_WCSTOK@
1269_GL_FUNCDECL_SYS (wcstok, wchar_t *, 1702_GL_FUNCDECL_SYS (wcstok, wchar_t *,
1270 (wchar_t *restrict wcs, const wchar_t *restrict delim, 1703 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1271 wchar_t **restrict ptr)); 1704 wchar_t **restrict ptr), );
1272# endif 1705# endif
1273_GL_CXXALIAS_SYS (wcstok, wchar_t *, 1706_GL_CXXALIAS_SYS (wcstok, wchar_t *,
1274 (wchar_t *restrict wcs, const wchar_t *restrict delim, 1707 (wchar_t *restrict wcs, const wchar_t *restrict delim,
@@ -1294,12 +1727,12 @@ _GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
1294# undef wcswidth 1727# undef wcswidth
1295# define wcswidth rpl_wcswidth 1728# define wcswidth rpl_wcswidth
1296# endif 1729# endif
1297_GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n) 1730_GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n),
1298 _GL_ATTRIBUTE_PURE); 1731 _GL_ATTRIBUTE_PURE);
1299_GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n)); 1732_GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
1300# else 1733# else
1301# if !@HAVE_WCSWIDTH@ 1734# if !@HAVE_WCSWIDTH@
1302_GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n) 1735_GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n),
1303 _GL_ATTRIBUTE_PURE); 1736 _GL_ATTRIBUTE_PURE);
1304# endif 1737# endif
1305_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n)); 1738_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
@@ -1327,7 +1760,7 @@ _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1327_GL_FUNCDECL_RPL (wcsftime, size_t, 1760_GL_FUNCDECL_RPL (wcsftime, size_t,
1328 (wchar_t *restrict __buf, size_t __bufsize, 1761 (wchar_t *restrict __buf, size_t __bufsize,
1329 const wchar_t *restrict __fmt, 1762 const wchar_t *restrict __fmt,
1330 const struct tm *restrict __tp) 1763 const struct tm *restrict __tp),
1331 _GL_ARG_NONNULL ((1, 3, 4))); 1764 _GL_ARG_NONNULL ((1, 3, 4)));
1332_GL_CXXALIAS_RPL (wcsftime, size_t, 1765_GL_CXXALIAS_RPL (wcsftime, size_t,
1333 (wchar_t *restrict __buf, size_t __bufsize, 1766 (wchar_t *restrict __buf, size_t __bufsize,
@@ -1338,7 +1771,7 @@ _GL_CXXALIAS_RPL (wcsftime, size_t,
1338_GL_FUNCDECL_SYS (wcsftime, size_t, 1771_GL_FUNCDECL_SYS (wcsftime, size_t,
1339 (wchar_t *restrict __buf, size_t __bufsize, 1772 (wchar_t *restrict __buf, size_t __bufsize,
1340 const wchar_t *restrict __fmt, 1773 const wchar_t *restrict __fmt,
1341 const struct tm *restrict __tp) 1774 const struct tm *restrict __tp),
1342 _GL_ARG_NONNULL ((1, 3, 4))); 1775 _GL_ARG_NONNULL ((1, 3, 4)));
1343# endif 1776# endif
1344_GL_CXXALIAS_SYS (wcsftime, size_t, 1777_GL_CXXALIAS_SYS (wcsftime, size_t,
@@ -1358,6 +1791,24 @@ _GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
1358#endif 1791#endif
1359 1792
1360 1793
1794#if @GNULIB_WGETCWD@ && (defined _WIN32 && !defined __CYGWIN__)
1795/* Gets the name of the current working directory.
1796 (a) If BUF is non-NULL, it is assumed to have room for SIZE wide characters.
1797 This function stores the working directory (NUL-terminated) in BUF and
1798 returns BUF.
1799 (b) If BUF is NULL, an array is allocated with 'malloc'. The array is SIZE
1800 wide characters long, unless SIZE == 0, in which case it is as big as
1801 necessary.
1802 If the directory couldn't be determined or SIZE was too small, this function
1803 returns NULL and sets errno. For a directory of length LEN, SIZE should be
1804 >= LEN + 3 in case (a) or >= LEN + 1 in case (b).
1805 Possible errno values include:
1806 - ERANGE if SIZE is too small.
1807 - ENOMEM if the memory could no be allocated. */
1808_GL_FUNCDECL_SYS (wgetcwd, wchar_t *, (wchar_t *buf, size_t size), );
1809#endif
1810
1811
1361#endif /* _@GUARD_PREFIX@_WCHAR_H */ 1812#endif /* _@GUARD_PREFIX@_WCHAR_H */
1362#endif /* _@GUARD_PREFIX@_WCHAR_H */ 1813#endif /* _@GUARD_PREFIX@_WCHAR_H */
1363#endif 1814#endif