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.h504
1 files changed, 392 insertions, 112 deletions
diff --git a/gl/wchar.in.h b/gl/wchar.in.h
index b6e4362..20315dd 100644
--- a/gl/wchar.in.h
+++ b/gl/wchar.in.h
@@ -1,25 +1,25 @@
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-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2021 Free Software Foundation, Inc.
4 4
5 This program 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 General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Eric Blake. */ 18/* Written by Eric Blake. */
19 19
20/* 20/*
21 * ISO C 99 <wchar.h> for platforms that have issues. 21 * ISO C 99 <wchar.h> for platforms that have issues.
22 * <http://www.opengroup.org/susv3xbd/wchar.h.html> 22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wchar.h.html>
23 * 23 *
24 * For now, this just ensures proper prerequisite inclusion order and 24 * For now, this just ensures proper prerequisite inclusion order and
25 * the declaration of wcwidth(). 25 * the declaration of wcwidth().
@@ -30,15 +30,24 @@
30#endif 30#endif
31@PRAGMA_COLUMNS@ 31@PRAGMA_COLUMNS@
32 32
33#if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H 33#if (((defined __need_mbstate_t || defined __need_wint_t) \
34 && !defined __MINGW32__) \
35 || (defined __hpux \
36 && ((defined _INTTYPES_INCLUDED \
37 && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \
38 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
39 || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
40 || defined _GL_ALREADY_INCLUDING_WCHAR_H)
34/* Special invocation convention: 41/* Special invocation convention:
35 - Inside glibc and uClibc header files. 42 - Inside glibc and uClibc header files, but not MinGW.
36 - 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
37 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>, 44 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
38 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h> 45 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
39 and once directly. In both situations 'wint_t' is not yet defined, 46 and once directly. In both situations 'wint_t' is not yet defined,
40 therefore we cannot provide the function overrides; instead include only 47 therefore we cannot provide the function overrides; instead include only
41 the system's <wchar.h>. 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'.
42 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and 51 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
43 the latter includes <wchar.h>. But here, we have no way to detect whether 52 the latter includes <wchar.h>. But here, we have no way to detect whether
44 <wctype.h> is completely included or is still being included. */ 53 <wctype.h> is completely included or is still being included. */
@@ -56,20 +65,12 @@
56# include <features.h> /* for __GLIBC__ */ 65# include <features.h> /* for __GLIBC__ */
57#endif 66#endif
58 67
59/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 68/* In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
60 <wchar.h>.
61 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
62 included before <wchar.h>.
63 In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
64 by <stddef.h>. 69 by <stddef.h>.
65 But avoid namespace pollution on glibc systems. */ 70 But avoid namespace pollution on glibc systems. */
66#if !(defined __GLIBC__ && !defined __UCLIBC__) 71#if !(defined __GLIBC__ && !defined __UCLIBC__)
67# include <stddef.h> 72# include <stddef.h>
68#endif 73#endif
69#ifndef __GLIBC__
70# include <stdio.h>
71# include <time.h>
72#endif
73 74
74/* Include the original <wchar.h> if it exists. 75/* Include the original <wchar.h> if it exists.
75 Some builds of uClibc lack it. */ 76 Some builds of uClibc lack it. */
@@ -83,12 +84,43 @@
83#ifndef _@GUARD_PREFIX@_WCHAR_H 84#ifndef _@GUARD_PREFIX@_WCHAR_H
84#define _@GUARD_PREFIX@_WCHAR_H 85#define _@GUARD_PREFIX@_WCHAR_H
85 86
87/* _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
89 function F. */
90#ifndef _GL_ATTRIBUTE_DEALLOC
91# if __GNUC__ >= 11
92# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
93# else
94# define _GL_ATTRIBUTE_DEALLOC(f, i)
95# endif
96#endif
97
98/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
99 can be freed via 'free'; it can be used only after declaring 'free'. */
100/* Applies to: functions. Cannot be used on inline functions. */
101#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
102# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
103#endif
104
105/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
106 allocated memory. */
107/* Applies to: functions. */
108#ifndef _GL_ATTRIBUTE_MALLOC
109# if __GNUC__ >= 3 || defined __clang__
110# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
111# else
112# define _GL_ATTRIBUTE_MALLOC
113# endif
114#endif
115
86/* The __attribute__ feature is available in gcc versions 2.5 and later. 116/* The __attribute__ feature is available in gcc versions 2.5 and later.
87 The attribute __pure__ was added in gcc 2.96. */ 117 The attribute __pure__ was added in gcc 2.96. */
88#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 118#ifndef _GL_ATTRIBUTE_PURE
89# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 119# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
90#else 120# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
91# define _GL_ATTRIBUTE_PURE /* empty */ 121# else
122# define _GL_ATTRIBUTE_PURE /* empty */
123# endif
92#endif 124#endif
93 125
94/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 126/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
@@ -105,12 +137,16 @@
105# define WEOF -1 137# define WEOF -1
106# endif 138# endif
107#else 139#else
108/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>. 140/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
109 This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be 141 <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
110 "unchanged by default argument promotions". Override it. */ 142 wint_t must be "unchanged by default argument promotions". Override it. */
111# if defined _MSC_VER 143# if @GNULIBHEADERS_OVERRIDE_WINT_T@
112# if !GNULIB_defined_wint_t 144# if !GNULIB_defined_wint_t
113# include <crtdefs.h> 145# if @HAVE_CRTDEFS_H@
146# include <crtdefs.h>
147# else
148# include <stddef.h>
149# endif
114typedef unsigned int rpl_wint_t; 150typedef unsigned int rpl_wint_t;
115# undef wint_t 151# undef wint_t
116# define wint_t rpl_wint_t 152# define wint_t rpl_wint_t
@@ -125,16 +161,29 @@ typedef unsigned int rpl_wint_t;
125 161
126/* Override mbstate_t if it is too small. 162/* Override mbstate_t if it is too small.
127 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for 163 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
128 implementing mbrtowc for encodings like UTF-8. */ 164 implementing mbrtowc for encodings like UTF-8.
129#if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ 165 On AIX and MSVC, mbrtowc needs to be overridden, but mbstate_t exists and is
166 large enough and overriding it would cause problems in C++ mode. */
167#if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
130# if !GNULIB_defined_mbstate_t 168# if !GNULIB_defined_mbstate_t
169# if !(defined _AIX || defined _MSC_VER)
131typedef int rpl_mbstate_t; 170typedef int rpl_mbstate_t;
132# undef mbstate_t 171# undef mbstate_t
133# define mbstate_t rpl_mbstate_t 172# define mbstate_t rpl_mbstate_t
173# endif
134# define GNULIB_defined_mbstate_t 1 174# define GNULIB_defined_mbstate_t 1
135# endif 175# endif
136#endif 176#endif
137 177
178/* Declare 'free' if needed for _GL_ATTRIBUTE_DEALLOC_FREE. */
179_GL_EXTERN_C void free (void *);
180#if @GNULIB_FREE_POSIX@
181# if (@REPLACE_FREE@ && !defined free \
182 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
183# define free rpl_free
184_GL_EXTERN_C void free (void *);
185# endif
186#endif
138 187
139/* Convert a single-byte character to a wide character. */ 188/* Convert a single-byte character to a wide character. */
140#if @GNULIB_BTOWC@ 189#if @GNULIB_BTOWC@
@@ -149,9 +198,12 @@ _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
149# if !@HAVE_BTOWC@ 198# if !@HAVE_BTOWC@
150_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); 199_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
151# endif 200# endif
152_GL_CXXALIAS_SYS (btowc, wint_t, (int c)); 201/* Need to cast, because on mingw, the return type is 'unsigned short'. */
202_GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c));
153# endif 203# endif
204# if __GLIBC__ >= 2
154_GL_CXXALIASWARN (btowc); 205_GL_CXXALIASWARN (btowc);
206# endif
155#elif defined GNULIB_POSIXCHECK 207#elif defined GNULIB_POSIXCHECK
156# undef btowc 208# undef btowc
157# if HAVE_RAW_DECL_BTOWC 209# if HAVE_RAW_DECL_BTOWC
@@ -177,7 +229,9 @@ _GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
177# endif 229# endif
178_GL_CXXALIAS_SYS (wctob, int, (wint_t wc)); 230_GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
179# endif 231# endif
232# if __GLIBC__ >= 2
180_GL_CXXALIASWARN (wctob); 233_GL_CXXALIASWARN (wctob);
234# endif
181#elif defined GNULIB_POSIXCHECK 235#elif defined GNULIB_POSIXCHECK
182# undef wctob 236# undef wctob
183# if HAVE_RAW_DECL_WCTOB 237# if HAVE_RAW_DECL_WCTOB
@@ -202,7 +256,9 @@ _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
202# endif 256# endif
203_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps)); 257_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
204# endif 258# endif
259# if __GLIBC__ >= 2
205_GL_CXXALIASWARN (mbsinit); 260_GL_CXXALIASWARN (mbsinit);
261# endif
206#elif defined GNULIB_POSIXCHECK 262#elif defined GNULIB_POSIXCHECK
207# undef mbsinit 263# undef mbsinit
208# if HAVE_RAW_DECL_MBSINIT 264# if HAVE_RAW_DECL_MBSINIT
@@ -220,18 +276,24 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
220# define mbrtowc rpl_mbrtowc 276# define mbrtowc rpl_mbrtowc
221# endif 277# endif
222_GL_FUNCDECL_RPL (mbrtowc, size_t, 278_GL_FUNCDECL_RPL (mbrtowc, size_t,
223 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); 279 (wchar_t *restrict pwc, const char *restrict s, size_t n,
280 mbstate_t *restrict ps));
224_GL_CXXALIAS_RPL (mbrtowc, size_t, 281_GL_CXXALIAS_RPL (mbrtowc, size_t,
225 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); 282 (wchar_t *restrict pwc, const char *restrict s, size_t n,
283 mbstate_t *restrict ps));
226# else 284# else
227# if !@HAVE_MBRTOWC@ 285# if !@HAVE_MBRTOWC@
228_GL_FUNCDECL_SYS (mbrtowc, size_t, 286_GL_FUNCDECL_SYS (mbrtowc, size_t,
229 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); 287 (wchar_t *restrict pwc, const char *restrict s, size_t n,
288 mbstate_t *restrict ps));
230# endif 289# endif
231_GL_CXXALIAS_SYS (mbrtowc, size_t, 290_GL_CXXALIAS_SYS (mbrtowc, size_t,
232 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); 291 (wchar_t *restrict pwc, const char *restrict s, size_t n,
292 mbstate_t *restrict ps));
233# endif 293# endif
294# if __GLIBC__ >= 2
234_GL_CXXALIASWARN (mbrtowc); 295_GL_CXXALIASWARN (mbrtowc);
296# endif
235#elif defined GNULIB_POSIXCHECK 297#elif defined GNULIB_POSIXCHECK
236# undef mbrtowc 298# undef mbrtowc
237# if HAVE_RAW_DECL_MBRTOWC 299# if HAVE_RAW_DECL_MBRTOWC
@@ -248,15 +310,21 @@ _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
248# undef mbrlen 310# undef mbrlen
249# define mbrlen rpl_mbrlen 311# define mbrlen rpl_mbrlen
250# endif 312# endif
251_GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); 313_GL_FUNCDECL_RPL (mbrlen, size_t,
252_GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); 314 (const char *restrict s, size_t n, mbstate_t *restrict ps));
315_GL_CXXALIAS_RPL (mbrlen, size_t,
316 (const char *restrict s, size_t n, mbstate_t *restrict ps));
253# else 317# else
254# if !@HAVE_MBRLEN@ 318# if !@HAVE_MBRLEN@
255_GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); 319_GL_FUNCDECL_SYS (mbrlen, size_t,
320 (const char *restrict s, size_t n, mbstate_t *restrict ps));
256# endif 321# endif
257_GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); 322_GL_CXXALIAS_SYS (mbrlen, size_t,
323 (const char *restrict s, size_t n, mbstate_t *restrict ps));
258# endif 324# endif
325# if __GLIBC__ >= 2
259_GL_CXXALIASWARN (mbrlen); 326_GL_CXXALIASWARN (mbrlen);
327# endif
260#elif defined GNULIB_POSIXCHECK 328#elif defined GNULIB_POSIXCHECK
261# undef mbrlen 329# undef mbrlen
262# if HAVE_RAW_DECL_MBRLEN 330# if HAVE_RAW_DECL_MBRLEN
@@ -274,22 +342,30 @@ _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
274# define mbsrtowcs rpl_mbsrtowcs 342# define mbsrtowcs rpl_mbsrtowcs
275# endif 343# endif
276_GL_FUNCDECL_RPL (mbsrtowcs, size_t, 344_GL_FUNCDECL_RPL (mbsrtowcs, size_t,
277 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) 345 (wchar_t *restrict dest,
346 const char **restrict srcp, size_t len,
347 mbstate_t *restrict ps)
278 _GL_ARG_NONNULL ((2))); 348 _GL_ARG_NONNULL ((2)));
279_GL_CXXALIAS_RPL (mbsrtowcs, size_t, 349_GL_CXXALIAS_RPL (mbsrtowcs, size_t,
280 (wchar_t *dest, const char **srcp, size_t len, 350 (wchar_t *restrict dest,
281 mbstate_t *ps)); 351 const char **restrict srcp, size_t len,
352 mbstate_t *restrict ps));
282# else 353# else
283# if !@HAVE_MBSRTOWCS@ 354# if !@HAVE_MBSRTOWCS@
284_GL_FUNCDECL_SYS (mbsrtowcs, size_t, 355_GL_FUNCDECL_SYS (mbsrtowcs, size_t,
285 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) 356 (wchar_t *restrict dest,
357 const char **restrict srcp, size_t len,
358 mbstate_t *restrict ps)
286 _GL_ARG_NONNULL ((2))); 359 _GL_ARG_NONNULL ((2)));
287# endif 360# endif
288_GL_CXXALIAS_SYS (mbsrtowcs, size_t, 361_GL_CXXALIAS_SYS (mbsrtowcs, size_t,
289 (wchar_t *dest, const char **srcp, size_t len, 362 (wchar_t *restrict dest,
290 mbstate_t *ps)); 363 const char **restrict srcp, size_t len,
364 mbstate_t *restrict ps));
291# endif 365# endif
366# if __GLIBC__ >= 2
292_GL_CXXALIASWARN (mbsrtowcs); 367_GL_CXXALIASWARN (mbsrtowcs);
368# endif
293#elif defined GNULIB_POSIXCHECK 369#elif defined GNULIB_POSIXCHECK
294# undef mbsrtowcs 370# undef mbsrtowcs
295# if HAVE_RAW_DECL_MBSRTOWCS 371# if HAVE_RAW_DECL_MBSRTOWCS
@@ -307,22 +383,26 @@ _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
307# define mbsnrtowcs rpl_mbsnrtowcs 383# define mbsnrtowcs rpl_mbsnrtowcs
308# endif 384# endif
309_GL_FUNCDECL_RPL (mbsnrtowcs, size_t, 385_GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
310 (wchar_t *dest, const char **srcp, size_t srclen, size_t len, 386 (wchar_t *restrict dest,
311 mbstate_t *ps) 387 const char **restrict srcp, size_t srclen, size_t len,
388 mbstate_t *restrict ps)
312 _GL_ARG_NONNULL ((2))); 389 _GL_ARG_NONNULL ((2)));
313_GL_CXXALIAS_RPL (mbsnrtowcs, size_t, 390_GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
314 (wchar_t *dest, const char **srcp, size_t srclen, size_t len, 391 (wchar_t *restrict dest,
315 mbstate_t *ps)); 392 const char **restrict srcp, size_t srclen, size_t len,
393 mbstate_t *restrict ps));
316# else 394# else
317# if !@HAVE_MBSNRTOWCS@ 395# if !@HAVE_MBSNRTOWCS@
318_GL_FUNCDECL_SYS (mbsnrtowcs, size_t, 396_GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
319 (wchar_t *dest, const char **srcp, size_t srclen, size_t len, 397 (wchar_t *restrict dest,
320 mbstate_t *ps) 398 const char **restrict srcp, size_t srclen, size_t len,
399 mbstate_t *restrict ps)
321 _GL_ARG_NONNULL ((2))); 400 _GL_ARG_NONNULL ((2)));
322# endif 401# endif
323_GL_CXXALIAS_SYS (mbsnrtowcs, size_t, 402_GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
324 (wchar_t *dest, const char **srcp, size_t srclen, size_t len, 403 (wchar_t *restrict dest,
325 mbstate_t *ps)); 404 const char **restrict srcp, size_t srclen, size_t len,
405 mbstate_t *restrict ps));
326# endif 406# endif
327_GL_CXXALIASWARN (mbsnrtowcs); 407_GL_CXXALIASWARN (mbsnrtowcs);
328#elif defined GNULIB_POSIXCHECK 408#elif defined GNULIB_POSIXCHECK
@@ -341,15 +421,21 @@ _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
341# undef wcrtomb 421# undef wcrtomb
342# define wcrtomb rpl_wcrtomb 422# define wcrtomb rpl_wcrtomb
343# endif 423# endif
344_GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); 424_GL_FUNCDECL_RPL (wcrtomb, size_t,
345_GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); 425 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
426_GL_CXXALIAS_RPL (wcrtomb, size_t,
427 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
346# else 428# else
347# if !@HAVE_WCRTOMB@ 429# if !@HAVE_WCRTOMB@
348_GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); 430_GL_FUNCDECL_SYS (wcrtomb, size_t,
431 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
349# endif 432# endif
350_GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); 433_GL_CXXALIAS_SYS (wcrtomb, size_t,
434 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
351# endif 435# endif
436# if __GLIBC__ >= 2
352_GL_CXXALIASWARN (wcrtomb); 437_GL_CXXALIASWARN (wcrtomb);
438# endif
353#elif defined GNULIB_POSIXCHECK 439#elif defined GNULIB_POSIXCHECK
354# undef wcrtomb 440# undef wcrtomb
355# if HAVE_RAW_DECL_WCRTOMB 441# if HAVE_RAW_DECL_WCRTOMB
@@ -367,22 +453,30 @@ _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
367# define wcsrtombs rpl_wcsrtombs 453# define wcsrtombs rpl_wcsrtombs
368# endif 454# endif
369_GL_FUNCDECL_RPL (wcsrtombs, size_t, 455_GL_FUNCDECL_RPL (wcsrtombs, size_t,
370 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) 456 (char *restrict dest, const wchar_t **restrict srcp,
457 size_t len,
458 mbstate_t *restrict ps)
371 _GL_ARG_NONNULL ((2))); 459 _GL_ARG_NONNULL ((2)));
372_GL_CXXALIAS_RPL (wcsrtombs, size_t, 460_GL_CXXALIAS_RPL (wcsrtombs, size_t,
373 (char *dest, const wchar_t **srcp, size_t len, 461 (char *restrict dest, const wchar_t **restrict srcp,
374 mbstate_t *ps)); 462 size_t len,
463 mbstate_t *restrict ps));
375# else 464# else
376# if !@HAVE_WCSRTOMBS@ 465# if !@HAVE_WCSRTOMBS@
377_GL_FUNCDECL_SYS (wcsrtombs, size_t, 466_GL_FUNCDECL_SYS (wcsrtombs, size_t,
378 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) 467 (char *restrict dest, const wchar_t **restrict srcp,
468 size_t len,
469 mbstate_t *restrict ps)
379 _GL_ARG_NONNULL ((2))); 470 _GL_ARG_NONNULL ((2)));
380# endif 471# endif
381_GL_CXXALIAS_SYS (wcsrtombs, size_t, 472_GL_CXXALIAS_SYS (wcsrtombs, size_t,
382 (char *dest, const wchar_t **srcp, size_t len, 473 (char *restrict dest, const wchar_t **restrict srcp,
383 mbstate_t *ps)); 474 size_t len,
475 mbstate_t *restrict ps));
384# endif 476# endif
477# if __GLIBC__ >= 2
385_GL_CXXALIASWARN (wcsrtombs); 478_GL_CXXALIASWARN (wcsrtombs);
479# endif
386#elif defined GNULIB_POSIXCHECK 480#elif defined GNULIB_POSIXCHECK
387# undef wcsrtombs 481# undef wcsrtombs
388# if HAVE_RAW_DECL_WCSRTOMBS 482# if HAVE_RAW_DECL_WCSRTOMBS
@@ -400,24 +494,34 @@ _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
400# define wcsnrtombs rpl_wcsnrtombs 494# define wcsnrtombs rpl_wcsnrtombs
401# endif 495# endif
402_GL_FUNCDECL_RPL (wcsnrtombs, size_t, 496_GL_FUNCDECL_RPL (wcsnrtombs, size_t,
403 (char *dest, const wchar_t **srcp, size_t srclen, size_t len, 497 (char *restrict dest,
404 mbstate_t *ps) 498 const wchar_t **restrict srcp, size_t srclen,
499 size_t len,
500 mbstate_t *restrict ps)
405 _GL_ARG_NONNULL ((2))); 501 _GL_ARG_NONNULL ((2)));
406_GL_CXXALIAS_RPL (wcsnrtombs, size_t, 502_GL_CXXALIAS_RPL (wcsnrtombs, size_t,
407 (char *dest, const wchar_t **srcp, size_t srclen, size_t len, 503 (char *restrict dest,
408 mbstate_t *ps)); 504 const wchar_t **restrict srcp, size_t srclen,
505 size_t len,
506 mbstate_t *restrict ps));
409# else 507# else
410# if !@HAVE_WCSNRTOMBS@ 508# if !@HAVE_WCSNRTOMBS@ || (defined __cplusplus && defined __sun)
411_GL_FUNCDECL_SYS (wcsnrtombs, size_t, 509_GL_FUNCDECL_SYS (wcsnrtombs, size_t,
412 (char *dest, const wchar_t **srcp, size_t srclen, size_t len, 510 (char *restrict dest,
413 mbstate_t *ps) 511 const wchar_t **restrict srcp, size_t srclen,
512 size_t len,
513 mbstate_t *restrict ps)
414 _GL_ARG_NONNULL ((2))); 514 _GL_ARG_NONNULL ((2)));
415# endif 515# endif
416_GL_CXXALIAS_SYS (wcsnrtombs, size_t, 516_GL_CXXALIAS_SYS (wcsnrtombs, size_t,
417 (char *dest, const wchar_t **srcp, size_t srclen, size_t len, 517 (char *restrict dest,
418 mbstate_t *ps)); 518 const wchar_t **restrict srcp, size_t srclen,
519 size_t len,
520 mbstate_t *restrict ps));
419# endif 521# endif
522# if __GLIBC__ >= 2
420_GL_CXXALIASWARN (wcsnrtombs); 523_GL_CXXALIASWARN (wcsnrtombs);
524# endif
421#elif defined GNULIB_POSIXCHECK 525#elif defined GNULIB_POSIXCHECK
422# undef wcsnrtombs 526# undef wcsnrtombs
423# if HAVE_RAW_DECL_WCSNRTOMBS 527# if HAVE_RAW_DECL_WCSNRTOMBS
@@ -443,7 +547,9 @@ _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
443# endif 547# endif
444_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t)); 548_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
445# endif 549# endif
550# if __GLIBC__ >= 2
446_GL_CXXALIASWARN (wcwidth); 551_GL_CXXALIASWARN (wcwidth);
552# endif
447#elif defined GNULIB_POSIXCHECK 553#elif defined GNULIB_POSIXCHECK
448# undef wcwidth 554# undef wcwidth
449# if HAVE_RAW_DECL_WCWIDTH 555# if HAVE_RAW_DECL_WCWIDTH
@@ -472,7 +578,7 @@ _GL_CXXALIAS_SYS_CAST2 (wmemchr,
472_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 578_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
473_GL_CXXALIASWARN1 (wmemchr, const wchar_t *, 579_GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
474 (const wchar_t *s, wchar_t c, size_t n)); 580 (const wchar_t *s, wchar_t c, size_t n));
475# else 581# elif __GLIBC__ >= 2
476_GL_CXXALIASWARN (wmemchr); 582_GL_CXXALIASWARN (wmemchr);
477# endif 583# endif
478#elif defined GNULIB_POSIXCHECK 584#elif defined GNULIB_POSIXCHECK
@@ -493,7 +599,9 @@ _GL_FUNCDECL_SYS (wmemcmp, int,
493# endif 599# endif
494_GL_CXXALIAS_SYS (wmemcmp, int, 600_GL_CXXALIAS_SYS (wmemcmp, int,
495 (const wchar_t *s1, const wchar_t *s2, size_t n)); 601 (const wchar_t *s1, const wchar_t *s2, size_t n));
602# if __GLIBC__ >= 2
496_GL_CXXALIASWARN (wmemcmp); 603_GL_CXXALIASWARN (wmemcmp);
604# endif
497#elif defined GNULIB_POSIXCHECK 605#elif defined GNULIB_POSIXCHECK
498# undef wmemcmp 606# undef wmemcmp
499# if HAVE_RAW_DECL_WMEMCMP 607# if HAVE_RAW_DECL_WMEMCMP
@@ -507,11 +615,15 @@ _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
507#if @GNULIB_WMEMCPY@ 615#if @GNULIB_WMEMCPY@
508# if !@HAVE_WMEMCPY@ 616# if !@HAVE_WMEMCPY@
509_GL_FUNCDECL_SYS (wmemcpy, wchar_t *, 617_GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
510 (wchar_t *dest, const wchar_t *src, size_t n)); 618 (wchar_t *restrict dest,
619 const wchar_t *restrict src, size_t n));
511# endif 620# endif
512_GL_CXXALIAS_SYS (wmemcpy, wchar_t *, 621_GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
513 (wchar_t *dest, const wchar_t *src, size_t n)); 622 (wchar_t *restrict dest,
623 const wchar_t *restrict src, size_t n));
624# if __GLIBC__ >= 2
514_GL_CXXALIASWARN (wmemcpy); 625_GL_CXXALIASWARN (wmemcpy);
626# endif
515#elif defined GNULIB_POSIXCHECK 627#elif defined GNULIB_POSIXCHECK
516# undef wmemcpy 628# undef wmemcpy
517# if HAVE_RAW_DECL_WMEMCPY 629# if HAVE_RAW_DECL_WMEMCPY
@@ -530,7 +642,9 @@ _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
530# endif 642# endif
531_GL_CXXALIAS_SYS (wmemmove, wchar_t *, 643_GL_CXXALIAS_SYS (wmemmove, wchar_t *,
532 (wchar_t *dest, const wchar_t *src, size_t n)); 644 (wchar_t *dest, const wchar_t *src, size_t n));
645# if __GLIBC__ >= 2
533_GL_CXXALIASWARN (wmemmove); 646_GL_CXXALIASWARN (wmemmove);
647# endif
534#elif defined GNULIB_POSIXCHECK 648#elif defined GNULIB_POSIXCHECK
535# undef wmemmove 649# undef wmemmove
536# if HAVE_RAW_DECL_WMEMMOVE 650# if HAVE_RAW_DECL_WMEMMOVE
@@ -540,13 +654,38 @@ _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
540#endif 654#endif
541 655
542 656
657/* Copy N wide characters of SRC to DEST.
658 Return pointer to wide characters after the last written wide character. */
659#if @GNULIB_WMEMPCPY@
660# if !@HAVE_WMEMPCPY@
661_GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
662 (wchar_t *restrict dest,
663 const wchar_t *restrict src, size_t n));
664# endif
665_GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
666 (wchar_t *restrict dest,
667 const wchar_t *restrict src, size_t n));
668# if __GLIBC__ >= 2
669_GL_CXXALIASWARN (wmempcpy);
670# endif
671#elif defined GNULIB_POSIXCHECK
672# undef wmempcpy
673# if HAVE_RAW_DECL_WMEMPCPY
674_GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
675 "use gnulib module wmempcpy for portability");
676# endif
677#endif
678
679
543/* Set N wide characters of S to C. */ 680/* Set N wide characters of S to C. */
544#if @GNULIB_WMEMSET@ 681#if @GNULIB_WMEMSET@
545# if !@HAVE_WMEMSET@ 682# if !@HAVE_WMEMSET@
546_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 683_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
547# endif 684# endif
548_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 685_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
686# if __GLIBC__ >= 2
549_GL_CXXALIASWARN (wmemset); 687_GL_CXXALIASWARN (wmemset);
688# endif
550#elif defined GNULIB_POSIXCHECK 689#elif defined GNULIB_POSIXCHECK
551# undef wmemset 690# undef wmemset
552# if HAVE_RAW_DECL_WMEMSET 691# if HAVE_RAW_DECL_WMEMSET
@@ -562,7 +701,9 @@ _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
562_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE); 701_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE);
563# endif 702# endif
564_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s)); 703_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
704# if __GLIBC__ >= 2
565_GL_CXXALIASWARN (wcslen); 705_GL_CXXALIASWARN (wcslen);
706# endif
566#elif defined GNULIB_POSIXCHECK 707#elif defined GNULIB_POSIXCHECK
567# undef wcslen 708# undef wcslen
568# if HAVE_RAW_DECL_WCSLEN 709# if HAVE_RAW_DECL_WCSLEN
@@ -592,10 +733,14 @@ _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
592/* Copy SRC to DEST. */ 733/* Copy SRC to DEST. */
593#if @GNULIB_WCSCPY@ 734#if @GNULIB_WCSCPY@
594# if !@HAVE_WCSCPY@ 735# if !@HAVE_WCSCPY@
595_GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); 736_GL_FUNCDECL_SYS (wcscpy, wchar_t *,
737 (wchar_t *restrict dest, const wchar_t *restrict src));
596# endif 738# endif
597_GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); 739_GL_CXXALIAS_SYS (wcscpy, wchar_t *,
740 (wchar_t *restrict dest, const wchar_t *restrict src));
741# if __GLIBC__ >= 2
598_GL_CXXALIASWARN (wcscpy); 742_GL_CXXALIASWARN (wcscpy);
743# endif
599#elif defined GNULIB_POSIXCHECK 744#elif defined GNULIB_POSIXCHECK
600# undef wcscpy 745# undef wcscpy
601# if HAVE_RAW_DECL_WCSCPY 746# if HAVE_RAW_DECL_WCSCPY
@@ -608,9 +753,11 @@ _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
608/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */ 753/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
609#if @GNULIB_WCPCPY@ 754#if @GNULIB_WCPCPY@
610# if !@HAVE_WCPCPY@ 755# if !@HAVE_WCPCPY@
611_GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); 756_GL_FUNCDECL_SYS (wcpcpy, wchar_t *,
757 (wchar_t *restrict dest, const wchar_t *restrict src));
612# endif 758# endif
613_GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); 759_GL_CXXALIAS_SYS (wcpcpy, wchar_t *,
760 (wchar_t *restrict dest, const wchar_t *restrict src));
614_GL_CXXALIASWARN (wcpcpy); 761_GL_CXXALIASWARN (wcpcpy);
615#elif defined GNULIB_POSIXCHECK 762#elif defined GNULIB_POSIXCHECK
616# undef wcpcpy 763# undef wcpcpy
@@ -625,11 +772,15 @@ _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
625#if @GNULIB_WCSNCPY@ 772#if @GNULIB_WCSNCPY@
626# if !@HAVE_WCSNCPY@ 773# if !@HAVE_WCSNCPY@
627_GL_FUNCDECL_SYS (wcsncpy, wchar_t *, 774_GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
628 (wchar_t *dest, const wchar_t *src, size_t n)); 775 (wchar_t *restrict dest,
776 const wchar_t *restrict src, size_t n));
629# endif 777# endif
630_GL_CXXALIAS_SYS (wcsncpy, wchar_t *, 778_GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
631 (wchar_t *dest, const wchar_t *src, size_t n)); 779 (wchar_t *restrict dest,
780 const wchar_t *restrict src, size_t n));
781# if __GLIBC__ >= 2
632_GL_CXXALIASWARN (wcsncpy); 782_GL_CXXALIASWARN (wcsncpy);
783# endif
633#elif defined GNULIB_POSIXCHECK 784#elif defined GNULIB_POSIXCHECK
634# undef wcsncpy 785# undef wcsncpy
635# if HAVE_RAW_DECL_WCSNCPY 786# if HAVE_RAW_DECL_WCSNCPY
@@ -644,10 +795,12 @@ _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
644#if @GNULIB_WCPNCPY@ 795#if @GNULIB_WCPNCPY@
645# if !@HAVE_WCPNCPY@ 796# if !@HAVE_WCPNCPY@
646_GL_FUNCDECL_SYS (wcpncpy, wchar_t *, 797_GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
647 (wchar_t *dest, const wchar_t *src, size_t n)); 798 (wchar_t *restrict dest,
799 const wchar_t *restrict src, size_t n));
648# endif 800# endif
649_GL_CXXALIAS_SYS (wcpncpy, wchar_t *, 801_GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
650 (wchar_t *dest, const wchar_t *src, size_t n)); 802 (wchar_t *restrict dest,
803 const wchar_t *restrict src, size_t n));
651_GL_CXXALIASWARN (wcpncpy); 804_GL_CXXALIASWARN (wcpncpy);
652#elif defined GNULIB_POSIXCHECK 805#elif defined GNULIB_POSIXCHECK
653# undef wcpncpy 806# undef wcpncpy
@@ -661,10 +814,14 @@ _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
661/* Append SRC onto DEST. */ 814/* Append SRC onto DEST. */
662#if @GNULIB_WCSCAT@ 815#if @GNULIB_WCSCAT@
663# if !@HAVE_WCSCAT@ 816# if !@HAVE_WCSCAT@
664_GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src)); 817_GL_FUNCDECL_SYS (wcscat, wchar_t *,
818 (wchar_t *restrict dest, const wchar_t *restrict src));
665# endif 819# endif
666_GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src)); 820_GL_CXXALIAS_SYS (wcscat, wchar_t *,
821 (wchar_t *restrict dest, const wchar_t *restrict src));
822# if __GLIBC__ >= 2
667_GL_CXXALIASWARN (wcscat); 823_GL_CXXALIASWARN (wcscat);
824# endif
668#elif defined GNULIB_POSIXCHECK 825#elif defined GNULIB_POSIXCHECK
669# undef wcscat 826# undef wcscat
670# if HAVE_RAW_DECL_WCSCAT 827# if HAVE_RAW_DECL_WCSCAT
@@ -678,11 +835,15 @@ _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
678#if @GNULIB_WCSNCAT@ 835#if @GNULIB_WCSNCAT@
679# if !@HAVE_WCSNCAT@ 836# if !@HAVE_WCSNCAT@
680_GL_FUNCDECL_SYS (wcsncat, wchar_t *, 837_GL_FUNCDECL_SYS (wcsncat, wchar_t *,
681 (wchar_t *dest, const wchar_t *src, size_t n)); 838 (wchar_t *restrict dest, const wchar_t *restrict src,
839 size_t n));
682# endif 840# endif
683_GL_CXXALIAS_SYS (wcsncat, wchar_t *, 841_GL_CXXALIAS_SYS (wcsncat, wchar_t *,
684 (wchar_t *dest, const wchar_t *src, size_t n)); 842 (wchar_t *restrict dest, const wchar_t *restrict src,
843 size_t n));
844# if __GLIBC__ >= 2
685_GL_CXXALIASWARN (wcsncat); 845_GL_CXXALIASWARN (wcsncat);
846# endif
686#elif defined GNULIB_POSIXCHECK 847#elif defined GNULIB_POSIXCHECK
687# undef wcsncat 848# undef wcsncat
688# if HAVE_RAW_DECL_WCSNCAT 849# if HAVE_RAW_DECL_WCSNCAT
@@ -699,7 +860,9 @@ _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)
699 _GL_ATTRIBUTE_PURE); 860 _GL_ATTRIBUTE_PURE);
700# endif 861# endif
701_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); 862_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
863# if __GLIBC__ >= 2
702_GL_CXXALIASWARN (wcscmp); 864_GL_CXXALIASWARN (wcscmp);
865# endif
703#elif defined GNULIB_POSIXCHECK 866#elif defined GNULIB_POSIXCHECK
704# undef wcscmp 867# undef wcscmp
705# if HAVE_RAW_DECL_WCSCMP 868# if HAVE_RAW_DECL_WCSCMP
@@ -718,7 +881,9 @@ _GL_FUNCDECL_SYS (wcsncmp, int,
718# endif 881# endif
719_GL_CXXALIAS_SYS (wcsncmp, int, 882_GL_CXXALIAS_SYS (wcsncmp, int,
720 (const wchar_t *s1, const wchar_t *s2, size_t n)); 883 (const wchar_t *s1, const wchar_t *s2, size_t n));
884# if __GLIBC__ >= 2
721_GL_CXXALIASWARN (wcsncmp); 885_GL_CXXALIASWARN (wcsncmp);
886# endif
722#elif defined GNULIB_POSIXCHECK 887#elif defined GNULIB_POSIXCHECK
723# undef wcsncmp 888# undef wcsncmp
724# if HAVE_RAW_DECL_WCSNCMP 889# if HAVE_RAW_DECL_WCSNCMP
@@ -771,7 +936,9 @@ _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
771_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); 936_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
772# endif 937# endif
773_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); 938_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
939# if __GLIBC__ >= 2
774_GL_CXXALIASWARN (wcscoll); 940_GL_CXXALIASWARN (wcscoll);
941# endif
775#elif defined GNULIB_POSIXCHECK 942#elif defined GNULIB_POSIXCHECK
776# undef wcscoll 943# undef wcscoll
777# if HAVE_RAW_DECL_WCSCOLL 944# if HAVE_RAW_DECL_WCSCOLL
@@ -786,10 +953,14 @@ _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
786 original strings. */ 953 original strings. */
787#if @GNULIB_WCSXFRM@ 954#if @GNULIB_WCSXFRM@
788# if !@HAVE_WCSXFRM@ 955# if !@HAVE_WCSXFRM@
789_GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n)); 956_GL_FUNCDECL_SYS (wcsxfrm, size_t,
957 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
790# endif 958# endif
791_GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n)); 959_GL_CXXALIAS_SYS (wcsxfrm, size_t,
960 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
961# if __GLIBC__ >= 2
792_GL_CXXALIASWARN (wcsxfrm); 962_GL_CXXALIASWARN (wcsxfrm);
963# endif
793#elif defined GNULIB_POSIXCHECK 964#elif defined GNULIB_POSIXCHECK
794# undef wcsxfrm 965# undef wcsxfrm
795# if HAVE_RAW_DECL_WCSXFRM 966# if HAVE_RAW_DECL_WCSXFRM
@@ -801,16 +972,55 @@ _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
801 972
802/* Duplicate S, returning an identical malloc'd string. */ 973/* Duplicate S, returning an identical malloc'd string. */
803#if @GNULIB_WCSDUP@ 974#if @GNULIB_WCSDUP@
804# if !@HAVE_WCSDUP@ 975# if defined _WIN32 && !defined __CYGWIN__
805_GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s)); 976# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
806# endif 977# undef wcsdup
978# define wcsdup _wcsdup
979# endif
980_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
981# else
982# if !@HAVE_WCSDUP@ || __GNUC__ >= 11
983_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
984 (const wchar_t *s)
985 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
986# endif
807_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); 987_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
988# endif
808_GL_CXXALIASWARN (wcsdup); 989_GL_CXXALIASWARN (wcsdup);
809#elif defined GNULIB_POSIXCHECK 990#else
810# undef wcsdup 991# if __GNUC__ >= 11 && !defined wcsdup
811# if HAVE_RAW_DECL_WCSDUP 992/* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */
993_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
994 (const wchar_t *s)
995 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
996# endif
997# if defined GNULIB_POSIXCHECK
998# undef wcsdup
999# if HAVE_RAW_DECL_WCSDUP
812_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - " 1000_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
813 "use gnulib module wcsdup for portability"); 1001 "use gnulib module wcsdup for portability");
1002# endif
1003# elif @GNULIB_MDA_WCSDUP@
1004/* On native Windows, map 'wcsdup' to '_wcsdup', so that -loldnames is not
1005 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1006 platforms by defining GNULIB_NAMESPACE::wcsdup always. */
1007# if defined _WIN32 && !defined __CYGWIN__
1008# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1009# undef wcsdup
1010# define wcsdup _wcsdup
1011# endif
1012_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1013# else
1014_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1015 (const wchar_t *s)
1016 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1017# if @HAVE_DECL_WCSDUP@
1018_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1019# endif
1020# endif
1021# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_WCSDUP@
1022_GL_CXXALIASWARN (wcsdup);
1023# endif
814# endif 1024# endif
815#endif 1025#endif
816 1026
@@ -833,7 +1043,7 @@ _GL_CXXALIAS_SYS_CAST2 (wcschr,
833 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1043 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
834_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc)); 1044_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
835_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); 1045_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
836# else 1046# elif __GLIBC__ >= 2
837_GL_CXXALIASWARN (wcschr); 1047_GL_CXXALIASWARN (wcschr);
838# endif 1048# endif
839#elif defined GNULIB_POSIXCHECK 1049#elif defined GNULIB_POSIXCHECK
@@ -863,7 +1073,7 @@ _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
863 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1073 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
864_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc)); 1074_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
865_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); 1075_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
866# else 1076# elif __GLIBC__ >= 2
867_GL_CXXALIASWARN (wcsrchr); 1077_GL_CXXALIASWARN (wcsrchr);
868# endif 1078# endif
869#elif defined GNULIB_POSIXCHECK 1079#elif defined GNULIB_POSIXCHECK
@@ -883,7 +1093,9 @@ _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)
883 _GL_ATTRIBUTE_PURE); 1093 _GL_ATTRIBUTE_PURE);
884# endif 1094# endif
885_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)); 1095_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
1096# if __GLIBC__ >= 2
886_GL_CXXALIASWARN (wcscspn); 1097_GL_CXXALIASWARN (wcscspn);
1098# endif
887#elif defined GNULIB_POSIXCHECK 1099#elif defined GNULIB_POSIXCHECK
888# undef wcscspn 1100# undef wcscspn
889# if HAVE_RAW_DECL_WCSCSPN 1101# if HAVE_RAW_DECL_WCSCSPN
@@ -901,7 +1113,9 @@ _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)
901 _GL_ATTRIBUTE_PURE); 1113 _GL_ATTRIBUTE_PURE);
902# endif 1114# endif
903_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)); 1115_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
1116# if __GLIBC__ >= 2
904_GL_CXXALIASWARN (wcsspn); 1117_GL_CXXALIASWARN (wcsspn);
1118# endif
905#elif defined GNULIB_POSIXCHECK 1119#elif defined GNULIB_POSIXCHECK
906# undef wcsspn 1120# undef wcsspn
907# if HAVE_RAW_DECL_WCSSPN 1121# if HAVE_RAW_DECL_WCSSPN
@@ -932,7 +1146,7 @@ _GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
932 (wchar_t *wcs, const wchar_t *accept)); 1146 (wchar_t *wcs, const wchar_t *accept));
933_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *, 1147_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
934 (const wchar_t *wcs, const wchar_t *accept)); 1148 (const wchar_t *wcs, const wchar_t *accept));
935# else 1149# elif __GLIBC__ >= 2
936_GL_CXXALIASWARN (wcspbrk); 1150_GL_CXXALIASWARN (wcspbrk);
937# endif 1151# endif
938#elif defined GNULIB_POSIXCHECK 1152#elif defined GNULIB_POSIXCHECK
@@ -948,7 +1162,8 @@ _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
948#if @GNULIB_WCSSTR@ 1162#if @GNULIB_WCSSTR@
949# if !@HAVE_WCSSTR@ 1163# if !@HAVE_WCSSTR@
950_GL_FUNCDECL_SYS (wcsstr, wchar_t *, 1164_GL_FUNCDECL_SYS (wcsstr, wchar_t *,
951 (const wchar_t *haystack, const wchar_t *needle) 1165 (const wchar_t *restrict haystack,
1166 const wchar_t *restrict needle)
952 _GL_ATTRIBUTE_PURE); 1167 _GL_ATTRIBUTE_PURE);
953# endif 1168# endif
954 /* On some systems, this function is defined as an overloaded function: 1169 /* On some systems, this function is defined as an overloaded function:
@@ -957,15 +1172,19 @@ _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
957 wchar_t * std::wcsstr (wchar_t *, const wchar_t *); 1172 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
958 } */ 1173 } */
959_GL_CXXALIAS_SYS_CAST2 (wcsstr, 1174_GL_CXXALIAS_SYS_CAST2 (wcsstr,
960 wchar_t *, (const wchar_t *, const wchar_t *), 1175 wchar_t *,
961 const wchar_t *, (const wchar_t *, const wchar_t *)); 1176 (const wchar_t *restrict, const wchar_t *restrict),
1177 const wchar_t *,
1178 (const wchar_t *restrict, const wchar_t *restrict));
962# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1179# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
963 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1180 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
964_GL_CXXALIASWARN1 (wcsstr, wchar_t *, 1181_GL_CXXALIASWARN1 (wcsstr, wchar_t *,
965 (wchar_t *haystack, const wchar_t *needle)); 1182 (wchar_t *restrict haystack,
1183 const wchar_t *restrict needle));
966_GL_CXXALIASWARN1 (wcsstr, const wchar_t *, 1184_GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
967 (const wchar_t *haystack, const wchar_t *needle)); 1185 (const wchar_t *restrict haystack,
968# else 1186 const wchar_t *restrict needle));
1187# elif __GLIBC__ >= 2
969_GL_CXXALIASWARN (wcsstr); 1188_GL_CXXALIASWARN (wcsstr);
970# endif 1189# endif
971#elif defined GNULIB_POSIXCHECK 1190#elif defined GNULIB_POSIXCHECK
@@ -979,13 +1198,30 @@ _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
979 1198
980/* Divide WCS into tokens separated by characters in DELIM. */ 1199/* Divide WCS into tokens separated by characters in DELIM. */
981#if @GNULIB_WCSTOK@ 1200#if @GNULIB_WCSTOK@
982# if !@HAVE_WCSTOK@ 1201# if @REPLACE_WCSTOK@
1202# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1203# undef wcstok
1204# define wcstok rpl_wcstok
1205# endif
1206_GL_FUNCDECL_RPL (wcstok, wchar_t *,
1207 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1208 wchar_t **restrict ptr));
1209_GL_CXXALIAS_RPL (wcstok, wchar_t *,
1210 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1211 wchar_t **restrict ptr));
1212# else
1213# if !@HAVE_WCSTOK@
983_GL_FUNCDECL_SYS (wcstok, wchar_t *, 1214_GL_FUNCDECL_SYS (wcstok, wchar_t *,
984 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); 1215 (wchar_t *restrict wcs, const wchar_t *restrict delim,
985# endif 1216 wchar_t **restrict ptr));
1217# endif
986_GL_CXXALIAS_SYS (wcstok, wchar_t *, 1218_GL_CXXALIAS_SYS (wcstok, wchar_t *,
987 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); 1219 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1220 wchar_t **restrict ptr));
1221# endif
1222# if __GLIBC__ >= 2
988_GL_CXXALIASWARN (wcstok); 1223_GL_CXXALIASWARN (wcstok);
1224# endif
989#elif defined GNULIB_POSIXCHECK 1225#elif defined GNULIB_POSIXCHECK
990# undef wcstok 1226# undef wcstok
991# if HAVE_RAW_DECL_WCSTOK 1227# if HAVE_RAW_DECL_WCSTOK
@@ -1013,7 +1249,9 @@ _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n)
1013# endif 1249# endif
1014_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n)); 1250_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
1015# endif 1251# endif
1252# if __GLIBC__ >= 2
1016_GL_CXXALIASWARN (wcswidth); 1253_GL_CXXALIASWARN (wcswidth);
1254# endif
1017#elif defined GNULIB_POSIXCHECK 1255#elif defined GNULIB_POSIXCHECK
1018# undef wcswidth 1256# undef wcswidth
1019# if HAVE_RAW_DECL_WCSWIDTH 1257# if HAVE_RAW_DECL_WCSWIDTH
@@ -1023,6 +1261,48 @@ _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1023#endif 1261#endif
1024 1262
1025 1263
1264/* Convert *TP to a date and time wide string. See
1265 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
1266#if @GNULIB_WCSFTIME@
1267# if @REPLACE_WCSFTIME@
1268# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1269# undef wcsftime
1270# define wcsftime rpl_wcsftime
1271# endif
1272_GL_FUNCDECL_RPL (wcsftime, size_t,
1273 (wchar_t *restrict __buf, size_t __bufsize,
1274 const wchar_t *restrict __fmt,
1275 const struct tm *restrict __tp)
1276 _GL_ARG_NONNULL ((1, 3, 4)));
1277_GL_CXXALIAS_RPL (wcsftime, size_t,
1278 (wchar_t *restrict __buf, size_t __bufsize,
1279 const wchar_t *restrict __fmt,
1280 const struct tm *restrict __tp));
1281# else
1282# if !@HAVE_WCSFTIME@
1283_GL_FUNCDECL_SYS (wcsftime, size_t,
1284 (wchar_t *restrict __buf, size_t __bufsize,
1285 const wchar_t *restrict __fmt,
1286 const struct tm *restrict __tp)
1287 _GL_ARG_NONNULL ((1, 3, 4)));
1288# endif
1289_GL_CXXALIAS_SYS (wcsftime, size_t,
1290 (wchar_t *restrict __buf, size_t __bufsize,
1291 const wchar_t *restrict __fmt,
1292 const struct tm *restrict __tp));
1293# endif
1294# if __GLIBC__ >= 2
1295_GL_CXXALIASWARN (wcsftime);
1296# endif
1297#elif defined GNULIB_POSIXCHECK
1298# undef wcsftime
1299# if HAVE_RAW_DECL_WCSFTIME
1300_GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
1301 "use gnulib module wcsftime for portability");
1302# endif
1303#endif
1304
1305
1026#endif /* _@GUARD_PREFIX@_WCHAR_H */ 1306#endif /* _@GUARD_PREFIX@_WCHAR_H */
1027#endif /* _@GUARD_PREFIX@_WCHAR_H */ 1307#endif /* _@GUARD_PREFIX@_WCHAR_H */
1028#endif 1308#endif