]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gnulib/import/wchar.in.h
Update gnulib
[thirdparty/binutils-gdb.git] / gnulib / import / wchar.in.h
CommitLineData
8690e634
JK
1/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
2
dc6c21da 3 Copyright (C) 2007-2022 Free Software Foundation, Inc.
8690e634 4
dc6c21da
TT
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
8690e634 9
dc6c21da 10 This file is distributed in the hope that it will be useful,
8690e634
JK
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dc6c21da 13 GNU Lesser General Public License for more details.
8690e634 14
dc6c21da
TT
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
8690e634
JK
17
18/* Written by Eric Blake. */
19
20/*
21 * ISO C 99 <wchar.h> for platforms that have issues.
c0c3707f 22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wchar.h.html>
8690e634
JK
23 *
24 * For now, this just ensures proper prerequisite inclusion order and
25 * the declaration of wcwidth().
26 */
27
28#if __GNUC__ >= 3
29@PRAGMA_SYSTEM_HEADER@
30#endif
31@PRAGMA_COLUMNS@
32
4a626d0a 33#if (((defined __need_mbstate_t || defined __need_wint_t) \
c0c3707f 34 && !defined __MINGW32__) \
4a626d0a 35 || (defined __hpux \
5df4cba6
SM
36 && ((defined _INTTYPES_INCLUDED \
37 && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \
4a626d0a 38 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
49e4877c 39 || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
4a626d0a 40 || defined _GL_ALREADY_INCLUDING_WCHAR_H)
8690e634 41/* Special invocation convention:
4a626d0a 42 - Inside glibc and uClibc header files, but not MinGW.
8690e634
JK
43 - On HP-UX 11.00 we have a sequence of nested includes
44 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
45 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
46 and once directly. In both situations 'wint_t' is not yet defined,
47 therefore we cannot provide the function overrides; instead include only
48 the system's <wchar.h>.
49e4877c
PA
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'.
8690e634
JK
51 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
52 the latter includes <wchar.h>. But here, we have no way to detect whether
53 <wctype.h> is completely included or is still being included. */
54
55#@INCLUDE_NEXT@ @NEXT_WCHAR_H@
56
57#else
58/* Normal invocation convention. */
59
60#ifndef _@GUARD_PREFIX@_WCHAR_H
61
62#define _GL_ALREADY_INCLUDING_WCHAR_H
63
64#if @HAVE_FEATURES_H@
65# include <features.h> /* for __GLIBC__ */
66#endif
67
9c9d63b1 68/* In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
8690e634
JK
69 by <stddef.h>.
70 But avoid namespace pollution on glibc systems. */
71#if !(defined __GLIBC__ && !defined __UCLIBC__)
72# include <stddef.h>
73#endif
8690e634
JK
74
75/* Include the original <wchar.h> if it exists.
76 Some builds of uClibc lack it. */
77/* The include_next requires a split double-inclusion guard. */
78#if @HAVE_WCHAR_H@
79# @INCLUDE_NEXT@ @NEXT_WCHAR_H@
80#endif
81
82#undef _GL_ALREADY_INCLUDING_WCHAR_H
83
84#ifndef _@GUARD_PREFIX@_WCHAR_H
85#define _@GUARD_PREFIX@_WCHAR_H
86
dc6c21da
TT
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
8690e634
JK
116/* The __attribute__ feature is available in gcc versions 2.5 and later.
117 The attribute __pure__ was added in gcc 2.96. */
698be2d8 118#ifndef _GL_ATTRIBUTE_PURE
9c9d63b1 119# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
698be2d8
CB
120# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
121# else
122# define _GL_ATTRIBUTE_PURE /* empty */
123# endif
8690e634
JK
124#endif
125
126/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
127
128/* The definition of _GL_ARG_NONNULL is copied here. */
129
130/* The definition of _GL_WARN_ON_USE is copied here. */
131
132
133/* Define wint_t and WEOF. (Also done in wctype.in.h.) */
134#if !@HAVE_WINT_T@ && !defined wint_t
135# define wint_t int
136# ifndef WEOF
137# define WEOF -1
138# endif
139#else
c0c3707f
CB
140/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
141 <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
142 wint_t must be "unchanged by default argument promotions". Override it. */
dc6c21da 143# if @GNULIBHEADERS_OVERRIDE_WINT_T@
8690e634 144# if !GNULIB_defined_wint_t
c0c3707f
CB
145# if @HAVE_CRTDEFS_H@
146# include <crtdefs.h>
147# else
148# include <stddef.h>
149# endif
8690e634
JK
150typedef unsigned int rpl_wint_t;
151# undef wint_t
152# define wint_t rpl_wint_t
153# define GNULIB_defined_wint_t 1
154# endif
155# endif
156# ifndef WEOF
157# define WEOF ((wint_t) -1)
158# endif
159#endif
160
161
162/* Override mbstate_t if it is too small.
163 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
c0c3707f
CB
164 implementing mbrtowc for encodings like UTF-8.
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. */
5df4cba6 167#if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
8690e634 168# if !GNULIB_defined_mbstate_t
5df4cba6 169# if !(defined _AIX || defined _MSC_VER)
8690e634 170typedef int rpl_mbstate_t;
5df4cba6
SM
171# undef mbstate_t
172# define mbstate_t rpl_mbstate_t
173# endif
8690e634
JK
174# define GNULIB_defined_mbstate_t 1
175# endif
176#endif
177
dc6c21da
TT
178/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
179 been included yet. */
180#if @GNULIB_FREE_POSIX@
181# if (@REPLACE_FREE@ && !defined free \
182 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
183/* We can't do '#define free rpl_free' here. */
184_GL_EXTERN_C void rpl_free (void *);
185# undef _GL_ATTRIBUTE_DEALLOC_FREE
186# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
187# else
188# if defined _MSC_VER
189_GL_EXTERN_C void __cdecl free (void *);
190# else
191# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
192_GL_EXTERN_C void free (void *) throw ();
193# else
194_GL_EXTERN_C void free (void *);
195# endif
196# endif
197# endif
198#else
199# if defined _MSC_VER
200_GL_EXTERN_C void __cdecl free (void *);
201# else
202# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
203_GL_EXTERN_C void free (void *) throw ();
204# else
205_GL_EXTERN_C void free (void *);
206# endif
207# endif
208#endif
8690e634
JK
209
210/* Convert a single-byte character to a wide character. */
211#if @GNULIB_BTOWC@
212# if @REPLACE_BTOWC@
213# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
214# undef btowc
215# define btowc rpl_btowc
216# endif
217_GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
218_GL_CXXALIAS_RPL (btowc, wint_t, (int c));
219# else
220# if !@HAVE_BTOWC@
221_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
222# endif
c0c3707f
CB
223/* Need to cast, because on mingw, the return type is 'unsigned short'. */
224_GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c));
8690e634 225# endif
c0c3707f 226# if __GLIBC__ >= 2
8690e634 227_GL_CXXALIASWARN (btowc);
c0c3707f 228# endif
8690e634
JK
229#elif defined GNULIB_POSIXCHECK
230# undef btowc
231# if HAVE_RAW_DECL_BTOWC
232_GL_WARN_ON_USE (btowc, "btowc is unportable - "
233 "use gnulib module btowc for portability");
234# endif
235#endif
236
237
238/* Convert a wide character to a single-byte character. */
239#if @GNULIB_WCTOB@
240# if @REPLACE_WCTOB@
241# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
242# undef wctob
243# define wctob rpl_wctob
244# endif
245_GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
246_GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
247# else
248# if !defined wctob && !@HAVE_DECL_WCTOB@
249/* wctob is provided by gnulib, or wctob exists but is not declared. */
250_GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
251# endif
252_GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
253# endif
c0c3707f 254# if __GLIBC__ >= 2
8690e634 255_GL_CXXALIASWARN (wctob);
c0c3707f 256# endif
8690e634
JK
257#elif defined GNULIB_POSIXCHECK
258# undef wctob
259# if HAVE_RAW_DECL_WCTOB
260_GL_WARN_ON_USE (wctob, "wctob is unportable - "
261 "use gnulib module wctob for portability");
262# endif
263#endif
264
265
266/* Test whether *PS is in the initial state. */
267#if @GNULIB_MBSINIT@
268# if @REPLACE_MBSINIT@
269# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
270# undef mbsinit
271# define mbsinit rpl_mbsinit
272# endif
273_GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
274_GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
275# else
276# if !@HAVE_MBSINIT@
277_GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
278# endif
279_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
280# endif
c0c3707f 281# if __GLIBC__ >= 2
8690e634 282_GL_CXXALIASWARN (mbsinit);
c0c3707f 283# endif
8690e634
JK
284#elif defined GNULIB_POSIXCHECK
285# undef mbsinit
286# if HAVE_RAW_DECL_MBSINIT
287_GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
288 "use gnulib module mbsinit for portability");
289# endif
290#endif
291
292
293/* Convert a multibyte character to a wide character. */
294#if @GNULIB_MBRTOWC@
295# if @REPLACE_MBRTOWC@
296# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
297# undef mbrtowc
298# define mbrtowc rpl_mbrtowc
299# endif
300_GL_FUNCDECL_RPL (mbrtowc, size_t,
698be2d8
CB
301 (wchar_t *restrict pwc, const char *restrict s, size_t n,
302 mbstate_t *restrict ps));
8690e634 303_GL_CXXALIAS_RPL (mbrtowc, size_t,
698be2d8
CB
304 (wchar_t *restrict pwc, const char *restrict s, size_t n,
305 mbstate_t *restrict ps));
8690e634
JK
306# else
307# if !@HAVE_MBRTOWC@
308_GL_FUNCDECL_SYS (mbrtowc, size_t,
698be2d8
CB
309 (wchar_t *restrict pwc, const char *restrict s, size_t n,
310 mbstate_t *restrict ps));
8690e634
JK
311# endif
312_GL_CXXALIAS_SYS (mbrtowc, size_t,
698be2d8
CB
313 (wchar_t *restrict pwc, const char *restrict s, size_t n,
314 mbstate_t *restrict ps));
8690e634 315# endif
c0c3707f 316# if __GLIBC__ >= 2
8690e634 317_GL_CXXALIASWARN (mbrtowc);
c0c3707f 318# endif
8690e634
JK
319#elif defined GNULIB_POSIXCHECK
320# undef mbrtowc
321# if HAVE_RAW_DECL_MBRTOWC
322_GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
323 "use gnulib module mbrtowc for portability");
324# endif
325#endif
326
327
328/* Recognize a multibyte character. */
329#if @GNULIB_MBRLEN@
330# if @REPLACE_MBRLEN@
331# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
332# undef mbrlen
333# define mbrlen rpl_mbrlen
334# endif
698be2d8
CB
335_GL_FUNCDECL_RPL (mbrlen, size_t,
336 (const char *restrict s, size_t n, mbstate_t *restrict ps));
337_GL_CXXALIAS_RPL (mbrlen, size_t,
338 (const char *restrict s, size_t n, mbstate_t *restrict ps));
8690e634
JK
339# else
340# if !@HAVE_MBRLEN@
698be2d8
CB
341_GL_FUNCDECL_SYS (mbrlen, size_t,
342 (const char *restrict s, size_t n, mbstate_t *restrict ps));
8690e634 343# endif
698be2d8
CB
344_GL_CXXALIAS_SYS (mbrlen, size_t,
345 (const char *restrict s, size_t n, mbstate_t *restrict ps));
8690e634 346# endif
c0c3707f 347# if __GLIBC__ >= 2
8690e634 348_GL_CXXALIASWARN (mbrlen);
c0c3707f 349# endif
8690e634
JK
350#elif defined GNULIB_POSIXCHECK
351# undef mbrlen
352# if HAVE_RAW_DECL_MBRLEN
353_GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
354 "use gnulib module mbrlen for portability");
355# endif
356#endif
357
358
359/* Convert a string to a wide string. */
360#if @GNULIB_MBSRTOWCS@
361# if @REPLACE_MBSRTOWCS@
362# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
363# undef mbsrtowcs
364# define mbsrtowcs rpl_mbsrtowcs
365# endif
366_GL_FUNCDECL_RPL (mbsrtowcs, size_t,
698be2d8
CB
367 (wchar_t *restrict dest,
368 const char **restrict srcp, size_t len,
369 mbstate_t *restrict ps)
8690e634
JK
370 _GL_ARG_NONNULL ((2)));
371_GL_CXXALIAS_RPL (mbsrtowcs, size_t,
698be2d8
CB
372 (wchar_t *restrict dest,
373 const char **restrict srcp, size_t len,
374 mbstate_t *restrict ps));
8690e634
JK
375# else
376# if !@HAVE_MBSRTOWCS@
377_GL_FUNCDECL_SYS (mbsrtowcs, size_t,
698be2d8
CB
378 (wchar_t *restrict dest,
379 const char **restrict srcp, size_t len,
380 mbstate_t *restrict ps)
8690e634
JK
381 _GL_ARG_NONNULL ((2)));
382# endif
383_GL_CXXALIAS_SYS (mbsrtowcs, size_t,
698be2d8
CB
384 (wchar_t *restrict dest,
385 const char **restrict srcp, size_t len,
386 mbstate_t *restrict ps));
8690e634 387# endif
c0c3707f 388# if __GLIBC__ >= 2
8690e634 389_GL_CXXALIASWARN (mbsrtowcs);
c0c3707f 390# endif
8690e634
JK
391#elif defined GNULIB_POSIXCHECK
392# undef mbsrtowcs
393# if HAVE_RAW_DECL_MBSRTOWCS
394_GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
395 "use gnulib module mbsrtowcs for portability");
396# endif
397#endif
398
399
400/* Convert a string to a wide string. */
401#if @GNULIB_MBSNRTOWCS@
402# if @REPLACE_MBSNRTOWCS@
403# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
404# undef mbsnrtowcs
405# define mbsnrtowcs rpl_mbsnrtowcs
406# endif
407_GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
698be2d8
CB
408 (wchar_t *restrict dest,
409 const char **restrict srcp, size_t srclen, size_t len,
410 mbstate_t *restrict ps)
8690e634
JK
411 _GL_ARG_NONNULL ((2)));
412_GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
698be2d8
CB
413 (wchar_t *restrict dest,
414 const char **restrict srcp, size_t srclen, size_t len,
415 mbstate_t *restrict ps));
8690e634
JK
416# else
417# if !@HAVE_MBSNRTOWCS@
418_GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
698be2d8
CB
419 (wchar_t *restrict dest,
420 const char **restrict srcp, size_t srclen, size_t len,
421 mbstate_t *restrict ps)
8690e634
JK
422 _GL_ARG_NONNULL ((2)));
423# endif
424_GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
698be2d8
CB
425 (wchar_t *restrict dest,
426 const char **restrict srcp, size_t srclen, size_t len,
427 mbstate_t *restrict ps));
8690e634
JK
428# endif
429_GL_CXXALIASWARN (mbsnrtowcs);
430#elif defined GNULIB_POSIXCHECK
431# undef mbsnrtowcs
432# if HAVE_RAW_DECL_MBSNRTOWCS
433_GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
434 "use gnulib module mbsnrtowcs for portability");
435# endif
436#endif
437
438
439/* Convert a wide character to a multibyte character. */
440#if @GNULIB_WCRTOMB@
441# if @REPLACE_WCRTOMB@
442# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
443# undef wcrtomb
444# define wcrtomb rpl_wcrtomb
445# endif
698be2d8
CB
446_GL_FUNCDECL_RPL (wcrtomb, size_t,
447 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
448_GL_CXXALIAS_RPL (wcrtomb, size_t,
449 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
8690e634
JK
450# else
451# if !@HAVE_WCRTOMB@
698be2d8
CB
452_GL_FUNCDECL_SYS (wcrtomb, size_t,
453 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
8690e634 454# endif
698be2d8
CB
455_GL_CXXALIAS_SYS (wcrtomb, size_t,
456 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
8690e634 457# endif
c0c3707f 458# if __GLIBC__ >= 2
8690e634 459_GL_CXXALIASWARN (wcrtomb);
c0c3707f 460# endif
8690e634
JK
461#elif defined GNULIB_POSIXCHECK
462# undef wcrtomb
463# if HAVE_RAW_DECL_WCRTOMB
464_GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
465 "use gnulib module wcrtomb for portability");
466# endif
467#endif
468
469
470/* Convert a wide string to a string. */
471#if @GNULIB_WCSRTOMBS@
472# if @REPLACE_WCSRTOMBS@
473# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
474# undef wcsrtombs
475# define wcsrtombs rpl_wcsrtombs
476# endif
477_GL_FUNCDECL_RPL (wcsrtombs, size_t,
698be2d8
CB
478 (char *restrict dest, const wchar_t **restrict srcp,
479 size_t len,
480 mbstate_t *restrict ps)
8690e634
JK
481 _GL_ARG_NONNULL ((2)));
482_GL_CXXALIAS_RPL (wcsrtombs, size_t,
698be2d8
CB
483 (char *restrict dest, const wchar_t **restrict srcp,
484 size_t len,
485 mbstate_t *restrict ps));
8690e634
JK
486# else
487# if !@HAVE_WCSRTOMBS@
488_GL_FUNCDECL_SYS (wcsrtombs, size_t,
698be2d8
CB
489 (char *restrict dest, const wchar_t **restrict srcp,
490 size_t len,
491 mbstate_t *restrict ps)
8690e634
JK
492 _GL_ARG_NONNULL ((2)));
493# endif
494_GL_CXXALIAS_SYS (wcsrtombs, size_t,
698be2d8
CB
495 (char *restrict dest, const wchar_t **restrict srcp,
496 size_t len,
497 mbstate_t *restrict ps));
8690e634 498# endif
c0c3707f 499# if __GLIBC__ >= 2
8690e634 500_GL_CXXALIASWARN (wcsrtombs);
c0c3707f 501# endif
8690e634
JK
502#elif defined GNULIB_POSIXCHECK
503# undef wcsrtombs
504# if HAVE_RAW_DECL_WCSRTOMBS
505_GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
506 "use gnulib module wcsrtombs for portability");
507# endif
508#endif
509
510
511/* Convert a wide string to a string. */
512#if @GNULIB_WCSNRTOMBS@
513# if @REPLACE_WCSNRTOMBS@
514# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
515# undef wcsnrtombs
516# define wcsnrtombs rpl_wcsnrtombs
517# endif
518_GL_FUNCDECL_RPL (wcsnrtombs, size_t,
698be2d8
CB
519 (char *restrict dest,
520 const wchar_t **restrict srcp, size_t srclen,
521 size_t len,
522 mbstate_t *restrict ps)
8690e634
JK
523 _GL_ARG_NONNULL ((2)));
524_GL_CXXALIAS_RPL (wcsnrtombs, size_t,
698be2d8
CB
525 (char *restrict dest,
526 const wchar_t **restrict srcp, size_t srclen,
527 size_t len,
528 mbstate_t *restrict ps));
8690e634 529# else
c0c3707f 530# if !@HAVE_WCSNRTOMBS@ || (defined __cplusplus && defined __sun)
8690e634 531_GL_FUNCDECL_SYS (wcsnrtombs, size_t,
698be2d8
CB
532 (char *restrict dest,
533 const wchar_t **restrict srcp, size_t srclen,
534 size_t len,
535 mbstate_t *restrict ps)
8690e634
JK
536 _GL_ARG_NONNULL ((2)));
537# endif
538_GL_CXXALIAS_SYS (wcsnrtombs, size_t,
698be2d8
CB
539 (char *restrict dest,
540 const wchar_t **restrict srcp, size_t srclen,
541 size_t len,
542 mbstate_t *restrict ps));
8690e634 543# endif
c0c3707f 544# if __GLIBC__ >= 2
8690e634 545_GL_CXXALIASWARN (wcsnrtombs);
c0c3707f 546# endif
8690e634
JK
547#elif defined GNULIB_POSIXCHECK
548# undef wcsnrtombs
549# if HAVE_RAW_DECL_WCSNRTOMBS
550_GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
551 "use gnulib module wcsnrtombs for portability");
552# endif
553#endif
554
555
556/* Return the number of screen columns needed for WC. */
557#if @GNULIB_WCWIDTH@
558# if @REPLACE_WCWIDTH@
559# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
560# undef wcwidth
561# define wcwidth rpl_wcwidth
562# endif
563_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
564_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
565# else
566# if !@HAVE_DECL_WCWIDTH@
567/* wcwidth exists but is not declared. */
568_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
569# endif
570_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
571# endif
c0c3707f 572# if __GLIBC__ >= 2
8690e634 573_GL_CXXALIASWARN (wcwidth);
c0c3707f 574# endif
8690e634
JK
575#elif defined GNULIB_POSIXCHECK
576# undef wcwidth
577# if HAVE_RAW_DECL_WCWIDTH
578_GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
579 "use gnulib module wcwidth for portability");
580# endif
581#endif
582
583
584/* Search N wide characters of S for C. */
585#if @GNULIB_WMEMCHR@
586# if !@HAVE_WMEMCHR@
587_GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n)
588 _GL_ATTRIBUTE_PURE);
589# endif
590 /* On some systems, this function is defined as an overloaded function:
591 extern "C++" {
592 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
593 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
594 } */
595_GL_CXXALIAS_SYS_CAST2 (wmemchr,
596 wchar_t *, (const wchar_t *, wchar_t, size_t),
597 const wchar_t *, (const wchar_t *, wchar_t, size_t));
598# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
599 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
600_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
601_GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
602 (const wchar_t *s, wchar_t c, size_t n));
c0c3707f 603# elif __GLIBC__ >= 2
8690e634
JK
604_GL_CXXALIASWARN (wmemchr);
605# endif
606#elif defined GNULIB_POSIXCHECK
607# undef wmemchr
608# if HAVE_RAW_DECL_WMEMCHR
609_GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
610 "use gnulib module wmemchr for portability");
611# endif
612#endif
613
614
615/* Compare N wide characters of S1 and S2. */
616#if @GNULIB_WMEMCMP@
617# if !@HAVE_WMEMCMP@
618_GL_FUNCDECL_SYS (wmemcmp, int,
619 (const wchar_t *s1, const wchar_t *s2, size_t n)
620 _GL_ATTRIBUTE_PURE);
621# endif
622_GL_CXXALIAS_SYS (wmemcmp, int,
623 (const wchar_t *s1, const wchar_t *s2, size_t n));
c0c3707f 624# if __GLIBC__ >= 2
8690e634 625_GL_CXXALIASWARN (wmemcmp);
c0c3707f 626# endif
8690e634
JK
627#elif defined GNULIB_POSIXCHECK
628# undef wmemcmp
629# if HAVE_RAW_DECL_WMEMCMP
630_GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
631 "use gnulib module wmemcmp for portability");
632# endif
633#endif
634
635
636/* Copy N wide characters of SRC to DEST. */
637#if @GNULIB_WMEMCPY@
638# if !@HAVE_WMEMCPY@
639_GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
698be2d8
CB
640 (wchar_t *restrict dest,
641 const wchar_t *restrict src, size_t n));
8690e634
JK
642# endif
643_GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
698be2d8
CB
644 (wchar_t *restrict dest,
645 const wchar_t *restrict src, size_t n));
c0c3707f 646# if __GLIBC__ >= 2
8690e634 647_GL_CXXALIASWARN (wmemcpy);
c0c3707f 648# endif
8690e634
JK
649#elif defined GNULIB_POSIXCHECK
650# undef wmemcpy
651# if HAVE_RAW_DECL_WMEMCPY
652_GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
653 "use gnulib module wmemcpy for portability");
654# endif
655#endif
656
657
658/* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
659 overlapping memory areas. */
660#if @GNULIB_WMEMMOVE@
661# if !@HAVE_WMEMMOVE@
662_GL_FUNCDECL_SYS (wmemmove, wchar_t *,
663 (wchar_t *dest, const wchar_t *src, size_t n));
664# endif
665_GL_CXXALIAS_SYS (wmemmove, wchar_t *,
666 (wchar_t *dest, const wchar_t *src, size_t n));
c0c3707f 667# if __GLIBC__ >= 2
8690e634 668_GL_CXXALIASWARN (wmemmove);
c0c3707f 669# endif
8690e634
JK
670#elif defined GNULIB_POSIXCHECK
671# undef wmemmove
672# if HAVE_RAW_DECL_WMEMMOVE
673_GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
674 "use gnulib module wmemmove for portability");
675# endif
676#endif
677
678
698be2d8
CB
679/* Copy N wide characters of SRC to DEST.
680 Return pointer to wide characters after the last written wide character. */
681#if @GNULIB_WMEMPCPY@
682# if !@HAVE_WMEMPCPY@
683_GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
684 (wchar_t *restrict dest,
685 const wchar_t *restrict src, size_t n));
686# endif
687_GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
688 (wchar_t *restrict dest,
689 const wchar_t *restrict src, size_t n));
690# if __GLIBC__ >= 2
691_GL_CXXALIASWARN (wmempcpy);
692# endif
693#elif defined GNULIB_POSIXCHECK
694# undef wmempcpy
695# if HAVE_RAW_DECL_WMEMPCPY
696_GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
697 "use gnulib module wmempcpy for portability");
698# endif
699#endif
700
701
8690e634
JK
702/* Set N wide characters of S to C. */
703#if @GNULIB_WMEMSET@
704# if !@HAVE_WMEMSET@
705_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
706# endif
707_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
c0c3707f 708# if __GLIBC__ >= 2
8690e634 709_GL_CXXALIASWARN (wmemset);
c0c3707f 710# endif
8690e634
JK
711#elif defined GNULIB_POSIXCHECK
712# undef wmemset
713# if HAVE_RAW_DECL_WMEMSET
714_GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
715 "use gnulib module wmemset for portability");
716# endif
717#endif
718
719
720/* Return the number of wide characters in S. */
721#if @GNULIB_WCSLEN@
722# if !@HAVE_WCSLEN@
723_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE);
724# endif
725_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
c0c3707f 726# if __GLIBC__ >= 2
8690e634 727_GL_CXXALIASWARN (wcslen);
c0c3707f 728# endif
8690e634
JK
729#elif defined GNULIB_POSIXCHECK
730# undef wcslen
731# if HAVE_RAW_DECL_WCSLEN
732_GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
733 "use gnulib module wcslen for portability");
734# endif
735#endif
736
737
738/* Return the number of wide characters in S, but at most MAXLEN. */
739#if @GNULIB_WCSNLEN@
740# if !@HAVE_WCSNLEN@
741_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)
742 _GL_ATTRIBUTE_PURE);
743# endif
744_GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
745_GL_CXXALIASWARN (wcsnlen);
746#elif defined GNULIB_POSIXCHECK
747# undef wcsnlen
748# if HAVE_RAW_DECL_WCSNLEN
749_GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
750 "use gnulib module wcsnlen for portability");
751# endif
752#endif
753
754
755/* Copy SRC to DEST. */
756#if @GNULIB_WCSCPY@
757# if !@HAVE_WCSCPY@
698be2d8
CB
758_GL_FUNCDECL_SYS (wcscpy, wchar_t *,
759 (wchar_t *restrict dest, const wchar_t *restrict src));
8690e634 760# endif
698be2d8
CB
761_GL_CXXALIAS_SYS (wcscpy, wchar_t *,
762 (wchar_t *restrict dest, const wchar_t *restrict src));
c0c3707f 763# if __GLIBC__ >= 2
8690e634 764_GL_CXXALIASWARN (wcscpy);
c0c3707f 765# endif
8690e634
JK
766#elif defined GNULIB_POSIXCHECK
767# undef wcscpy
768# if HAVE_RAW_DECL_WCSCPY
769_GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
770 "use gnulib module wcscpy for portability");
771# endif
772#endif
773
774
775/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
776#if @GNULIB_WCPCPY@
777# if !@HAVE_WCPCPY@
698be2d8
CB
778_GL_FUNCDECL_SYS (wcpcpy, wchar_t *,
779 (wchar_t *restrict dest, const wchar_t *restrict src));
8690e634 780# endif
698be2d8
CB
781_GL_CXXALIAS_SYS (wcpcpy, wchar_t *,
782 (wchar_t *restrict dest, const wchar_t *restrict src));
8690e634
JK
783_GL_CXXALIASWARN (wcpcpy);
784#elif defined GNULIB_POSIXCHECK
785# undef wcpcpy
786# if HAVE_RAW_DECL_WCPCPY
787_GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
788 "use gnulib module wcpcpy for portability");
789# endif
790#endif
791
792
793/* Copy no more than N wide characters of SRC to DEST. */
794#if @GNULIB_WCSNCPY@
795# if !@HAVE_WCSNCPY@
796_GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
698be2d8
CB
797 (wchar_t *restrict dest,
798 const wchar_t *restrict src, size_t n));
8690e634
JK
799# endif
800_GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
698be2d8
CB
801 (wchar_t *restrict dest,
802 const wchar_t *restrict src, size_t n));
c0c3707f 803# if __GLIBC__ >= 2
8690e634 804_GL_CXXALIASWARN (wcsncpy);
c0c3707f 805# endif
8690e634
JK
806#elif defined GNULIB_POSIXCHECK
807# undef wcsncpy
808# if HAVE_RAW_DECL_WCSNCPY
809_GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
810 "use gnulib module wcsncpy for portability");
811# endif
812#endif
813
814
815/* Copy no more than N characters of SRC to DEST, returning the address of
816 the last character written into DEST. */
817#if @GNULIB_WCPNCPY@
818# if !@HAVE_WCPNCPY@
819_GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
698be2d8
CB
820 (wchar_t *restrict dest,
821 const wchar_t *restrict src, size_t n));
8690e634
JK
822# endif
823_GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
698be2d8
CB
824 (wchar_t *restrict dest,
825 const wchar_t *restrict src, size_t n));
8690e634
JK
826_GL_CXXALIASWARN (wcpncpy);
827#elif defined GNULIB_POSIXCHECK
828# undef wcpncpy
829# if HAVE_RAW_DECL_WCPNCPY
830_GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
831 "use gnulib module wcpncpy for portability");
832# endif
833#endif
834
835
836/* Append SRC onto DEST. */
837#if @GNULIB_WCSCAT@
838# if !@HAVE_WCSCAT@
698be2d8
CB
839_GL_FUNCDECL_SYS (wcscat, wchar_t *,
840 (wchar_t *restrict dest, const wchar_t *restrict src));
8690e634 841# endif
698be2d8
CB
842_GL_CXXALIAS_SYS (wcscat, wchar_t *,
843 (wchar_t *restrict dest, const wchar_t *restrict src));
c0c3707f 844# if __GLIBC__ >= 2
8690e634 845_GL_CXXALIASWARN (wcscat);
c0c3707f 846# endif
8690e634
JK
847#elif defined GNULIB_POSIXCHECK
848# undef wcscat
849# if HAVE_RAW_DECL_WCSCAT
850_GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
851 "use gnulib module wcscat for portability");
852# endif
853#endif
854
855
856/* Append no more than N wide characters of SRC onto DEST. */
857#if @GNULIB_WCSNCAT@
858# if !@HAVE_WCSNCAT@
859_GL_FUNCDECL_SYS (wcsncat, wchar_t *,
698be2d8
CB
860 (wchar_t *restrict dest, const wchar_t *restrict src,
861 size_t n));
8690e634
JK
862# endif
863_GL_CXXALIAS_SYS (wcsncat, wchar_t *,
698be2d8
CB
864 (wchar_t *restrict dest, const wchar_t *restrict src,
865 size_t n));
c0c3707f 866# if __GLIBC__ >= 2
8690e634 867_GL_CXXALIASWARN (wcsncat);
c0c3707f 868# endif
8690e634
JK
869#elif defined GNULIB_POSIXCHECK
870# undef wcsncat
871# if HAVE_RAW_DECL_WCSNCAT
872_GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
873 "use gnulib module wcsncat for portability");
874# endif
875#endif
876
877
878/* Compare S1 and S2. */
879#if @GNULIB_WCSCMP@
880# if !@HAVE_WCSCMP@
881_GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)
882 _GL_ATTRIBUTE_PURE);
883# endif
884_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
c0c3707f 885# if __GLIBC__ >= 2
8690e634 886_GL_CXXALIASWARN (wcscmp);
c0c3707f 887# endif
8690e634
JK
888#elif defined GNULIB_POSIXCHECK
889# undef wcscmp
890# if HAVE_RAW_DECL_WCSCMP
891_GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
892 "use gnulib module wcscmp for portability");
893# endif
894#endif
895
896
897/* Compare no more than N wide characters of S1 and S2. */
898#if @GNULIB_WCSNCMP@
899# if !@HAVE_WCSNCMP@
900_GL_FUNCDECL_SYS (wcsncmp, int,
901 (const wchar_t *s1, const wchar_t *s2, size_t n)
902 _GL_ATTRIBUTE_PURE);
903# endif
904_GL_CXXALIAS_SYS (wcsncmp, int,
905 (const wchar_t *s1, const wchar_t *s2, size_t n));
c0c3707f 906# if __GLIBC__ >= 2
8690e634 907_GL_CXXALIASWARN (wcsncmp);
c0c3707f 908# endif
8690e634
JK
909#elif defined GNULIB_POSIXCHECK
910# undef wcsncmp
911# if HAVE_RAW_DECL_WCSNCMP
912_GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
913 "use gnulib module wcsncmp for portability");
914# endif
915#endif
916
917
918/* Compare S1 and S2, ignoring case. */
919#if @GNULIB_WCSCASECMP@
920# if !@HAVE_WCSCASECMP@
921_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)
922 _GL_ATTRIBUTE_PURE);
923# endif
924_GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
925_GL_CXXALIASWARN (wcscasecmp);
926#elif defined GNULIB_POSIXCHECK
927# undef wcscasecmp
928# if HAVE_RAW_DECL_WCSCASECMP
929_GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
930 "use gnulib module wcscasecmp for portability");
931# endif
932#endif
933
934
935/* Compare no more than N chars of S1 and S2, ignoring case. */
936#if @GNULIB_WCSNCASECMP@
937# if !@HAVE_WCSNCASECMP@
938_GL_FUNCDECL_SYS (wcsncasecmp, int,
939 (const wchar_t *s1, const wchar_t *s2, size_t n)
940 _GL_ATTRIBUTE_PURE);
941# endif
942_GL_CXXALIAS_SYS (wcsncasecmp, int,
943 (const wchar_t *s1, const wchar_t *s2, size_t n));
944_GL_CXXALIASWARN (wcsncasecmp);
945#elif defined GNULIB_POSIXCHECK
946# undef wcsncasecmp
947# if HAVE_RAW_DECL_WCSNCASECMP
948_GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
949 "use gnulib module wcsncasecmp for portability");
950# endif
951#endif
952
953
954/* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
955 category of the current locale. */
956#if @GNULIB_WCSCOLL@
957# if !@HAVE_WCSCOLL@
958_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
959# endif
960_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
c0c3707f 961# if __GLIBC__ >= 2
8690e634 962_GL_CXXALIASWARN (wcscoll);
c0c3707f 963# endif
8690e634
JK
964#elif defined GNULIB_POSIXCHECK
965# undef wcscoll
966# if HAVE_RAW_DECL_WCSCOLL
967_GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
968 "use gnulib module wcscoll for portability");
969# endif
970#endif
971
972
973/* Transform S2 into array pointed to by S1 such that if wcscmp is applied
974 to two transformed strings the result is the as applying 'wcscoll' to the
975 original strings. */
976#if @GNULIB_WCSXFRM@
977# if !@HAVE_WCSXFRM@
698be2d8
CB
978_GL_FUNCDECL_SYS (wcsxfrm, size_t,
979 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
8690e634 980# endif
698be2d8
CB
981_GL_CXXALIAS_SYS (wcsxfrm, size_t,
982 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
c0c3707f 983# if __GLIBC__ >= 2
8690e634 984_GL_CXXALIASWARN (wcsxfrm);
c0c3707f 985# endif
8690e634
JK
986#elif defined GNULIB_POSIXCHECK
987# undef wcsxfrm
988# if HAVE_RAW_DECL_WCSXFRM
989_GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
990 "use gnulib module wcsxfrm for portability");
991# endif
992#endif
993
994
995/* Duplicate S, returning an identical malloc'd string. */
996#if @GNULIB_WCSDUP@
9c9d63b1
PM
997# if defined _WIN32 && !defined __CYGWIN__
998# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
999# undef wcsdup
1000# define wcsdup _wcsdup
1001# endif
1002_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1003# else
dc6c21da
TT
1004# if !@HAVE_WCSDUP@ || __GNUC__ >= 11
1005_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1006 (const wchar_t *s)
1007 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
9c9d63b1 1008# endif
8690e634 1009_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
9c9d63b1 1010# endif
8690e634 1011_GL_CXXALIASWARN (wcsdup);
dc6c21da
TT
1012#else
1013# if __GNUC__ >= 11 && !defined wcsdup
1014/* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */
1015_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1016 (const wchar_t *s)
1017 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1018# endif
1019# if defined GNULIB_POSIXCHECK
1020# undef wcsdup
1021# if HAVE_RAW_DECL_WCSDUP
8690e634
JK
1022_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
1023 "use gnulib module wcsdup for portability");
dc6c21da
TT
1024# endif
1025# elif @GNULIB_MDA_WCSDUP@
9c9d63b1
PM
1026/* On native Windows, map 'wcsdup' to '_wcsdup', so that -loldnames is not
1027 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1028 platforms by defining GNULIB_NAMESPACE::wcsdup always. */
dc6c21da
TT
1029# if defined _WIN32 && !defined __CYGWIN__
1030# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1031# undef wcsdup
1032# define wcsdup _wcsdup
1033# endif
9c9d63b1 1034_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
dc6c21da
TT
1035# else
1036_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1037 (const wchar_t *s)
1038 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1039# if @HAVE_DECL_WCSDUP@
9c9d63b1 1040_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
dc6c21da 1041# endif
9c9d63b1 1042# endif
dc6c21da 1043# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_WCSDUP@
9c9d63b1 1044_GL_CXXALIASWARN (wcsdup);
dc6c21da 1045# endif
9c9d63b1 1046# endif
8690e634
JK
1047#endif
1048
1049
1050/* Find the first occurrence of WC in WCS. */
1051#if @GNULIB_WCSCHR@
1052# if !@HAVE_WCSCHR@
1053_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
1054 _GL_ATTRIBUTE_PURE);
1055# endif
1056 /* On some systems, this function is defined as an overloaded function:
1057 extern "C++" {
1058 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
1059 wchar_t * std::wcschr (wchar_t *, wchar_t);
1060 } */
1061_GL_CXXALIAS_SYS_CAST2 (wcschr,
1062 wchar_t *, (const wchar_t *, wchar_t),
1063 const wchar_t *, (const wchar_t *, wchar_t));
1064# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1065 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1066_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
1067_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
c0c3707f 1068# elif __GLIBC__ >= 2
8690e634
JK
1069_GL_CXXALIASWARN (wcschr);
1070# endif
1071#elif defined GNULIB_POSIXCHECK
1072# undef wcschr
1073# if HAVE_RAW_DECL_WCSCHR
1074_GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
1075 "use gnulib module wcschr for portability");
1076# endif
1077#endif
1078
1079
1080/* Find the last occurrence of WC in WCS. */
1081#if @GNULIB_WCSRCHR@
1082# if !@HAVE_WCSRCHR@
1083_GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
1084 _GL_ATTRIBUTE_PURE);
1085# endif
1086 /* On some systems, this function is defined as an overloaded function:
1087 extern "C++" {
1088 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
1089 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
1090 } */
1091_GL_CXXALIAS_SYS_CAST2 (wcsrchr,
1092 wchar_t *, (const wchar_t *, wchar_t),
1093 const wchar_t *, (const wchar_t *, wchar_t));
1094# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1095 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1096_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
1097_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
c0c3707f 1098# elif __GLIBC__ >= 2
8690e634
JK
1099_GL_CXXALIASWARN (wcsrchr);
1100# endif
1101#elif defined GNULIB_POSIXCHECK
1102# undef wcsrchr
1103# if HAVE_RAW_DECL_WCSRCHR
1104_GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
1105 "use gnulib module wcsrchr for portability");
1106# endif
1107#endif
1108
1109
1110/* Return the length of the initial segmet of WCS which consists entirely
1111 of wide characters not in REJECT. */
1112#if @GNULIB_WCSCSPN@
1113# if !@HAVE_WCSCSPN@
1114_GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)
1115 _GL_ATTRIBUTE_PURE);
1116# endif
1117_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
c0c3707f 1118# if __GLIBC__ >= 2
8690e634 1119_GL_CXXALIASWARN (wcscspn);
c0c3707f 1120# endif
8690e634
JK
1121#elif defined GNULIB_POSIXCHECK
1122# undef wcscspn
1123# if HAVE_RAW_DECL_WCSCSPN
1124_GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
1125 "use gnulib module wcscspn for portability");
1126# endif
1127#endif
1128
1129
1130/* Return the length of the initial segmet of WCS which consists entirely
1131 of wide characters in ACCEPT. */
1132#if @GNULIB_WCSSPN@
1133# if !@HAVE_WCSSPN@
1134_GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)
1135 _GL_ATTRIBUTE_PURE);
1136# endif
1137_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
c0c3707f 1138# if __GLIBC__ >= 2
8690e634 1139_GL_CXXALIASWARN (wcsspn);
c0c3707f 1140# endif
8690e634
JK
1141#elif defined GNULIB_POSIXCHECK
1142# undef wcsspn
1143# if HAVE_RAW_DECL_WCSSPN
1144_GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
1145 "use gnulib module wcsspn for portability");
1146# endif
1147#endif
1148
1149
1150/* Find the first occurrence in WCS of any character in ACCEPT. */
1151#if @GNULIB_WCSPBRK@
1152# if !@HAVE_WCSPBRK@
1153_GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
1154 (const wchar_t *wcs, const wchar_t *accept)
1155 _GL_ATTRIBUTE_PURE);
1156# endif
1157 /* On some systems, this function is defined as an overloaded function:
1158 extern "C++" {
1159 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
1160 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
1161 } */
1162_GL_CXXALIAS_SYS_CAST2 (wcspbrk,
1163 wchar_t *, (const wchar_t *, const wchar_t *),
1164 const wchar_t *, (const wchar_t *, const wchar_t *));
1165# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1166 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1167_GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
1168 (wchar_t *wcs, const wchar_t *accept));
1169_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
1170 (const wchar_t *wcs, const wchar_t *accept));
c0c3707f 1171# elif __GLIBC__ >= 2
8690e634
JK
1172_GL_CXXALIASWARN (wcspbrk);
1173# endif
1174#elif defined GNULIB_POSIXCHECK
1175# undef wcspbrk
1176# if HAVE_RAW_DECL_WCSPBRK
1177_GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
1178 "use gnulib module wcspbrk for portability");
1179# endif
1180#endif
1181
1182
1183/* Find the first occurrence of NEEDLE in HAYSTACK. */
1184#if @GNULIB_WCSSTR@
1185# if !@HAVE_WCSSTR@
1186_GL_FUNCDECL_SYS (wcsstr, wchar_t *,
698be2d8
CB
1187 (const wchar_t *restrict haystack,
1188 const wchar_t *restrict needle)
8690e634
JK
1189 _GL_ATTRIBUTE_PURE);
1190# endif
1191 /* On some systems, this function is defined as an overloaded function:
1192 extern "C++" {
1193 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
1194 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
1195 } */
1196_GL_CXXALIAS_SYS_CAST2 (wcsstr,
698be2d8
CB
1197 wchar_t *,
1198 (const wchar_t *restrict, const wchar_t *restrict),
1199 const wchar_t *,
1200 (const wchar_t *restrict, const wchar_t *restrict));
8690e634
JK
1201# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1202 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1203_GL_CXXALIASWARN1 (wcsstr, wchar_t *,
698be2d8
CB
1204 (wchar_t *restrict haystack,
1205 const wchar_t *restrict needle));
8690e634 1206_GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
698be2d8
CB
1207 (const wchar_t *restrict haystack,
1208 const wchar_t *restrict needle));
c0c3707f 1209# elif __GLIBC__ >= 2
8690e634
JK
1210_GL_CXXALIASWARN (wcsstr);
1211# endif
1212#elif defined GNULIB_POSIXCHECK
1213# undef wcsstr
1214# if HAVE_RAW_DECL_WCSSTR
1215_GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
1216 "use gnulib module wcsstr for portability");
1217# endif
1218#endif
1219
1220
1221/* Divide WCS into tokens separated by characters in DELIM. */
1222#if @GNULIB_WCSTOK@
c0c3707f
CB
1223# if @REPLACE_WCSTOK@
1224# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1225# undef wcstok
1226# define wcstok rpl_wcstok
1227# endif
1228_GL_FUNCDECL_RPL (wcstok, wchar_t *,
698be2d8
CB
1229 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1230 wchar_t **restrict ptr));
c0c3707f 1231_GL_CXXALIAS_RPL (wcstok, wchar_t *,
698be2d8
CB
1232 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1233 wchar_t **restrict ptr));
c0c3707f
CB
1234# else
1235# if !@HAVE_WCSTOK@
8690e634 1236_GL_FUNCDECL_SYS (wcstok, wchar_t *,
698be2d8
CB
1237 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1238 wchar_t **restrict ptr));
c0c3707f 1239# endif
8690e634 1240_GL_CXXALIAS_SYS (wcstok, wchar_t *,
698be2d8
CB
1241 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1242 wchar_t **restrict ptr));
c0c3707f
CB
1243# endif
1244# if __GLIBC__ >= 2
8690e634 1245_GL_CXXALIASWARN (wcstok);
c0c3707f 1246# endif
8690e634
JK
1247#elif defined GNULIB_POSIXCHECK
1248# undef wcstok
1249# if HAVE_RAW_DECL_WCSTOK
1250_GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
1251 "use gnulib module wcstok for portability");
1252# endif
1253#endif
1254
1255
1256/* Determine number of column positions required for first N wide
1257 characters (or fewer if S ends before this) in S. */
1258#if @GNULIB_WCSWIDTH@
1259# if @REPLACE_WCSWIDTH@
1260# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1261# undef wcswidth
1262# define wcswidth rpl_wcswidth
1263# endif
1264_GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n)
1265 _GL_ATTRIBUTE_PURE);
1266_GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
1267# else
1268# if !@HAVE_WCSWIDTH@
1269_GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n)
1270 _GL_ATTRIBUTE_PURE);
1271# endif
1272_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
1273# endif
c0c3707f 1274# if __GLIBC__ >= 2
8690e634 1275_GL_CXXALIASWARN (wcswidth);
c0c3707f 1276# endif
8690e634
JK
1277#elif defined GNULIB_POSIXCHECK
1278# undef wcswidth
1279# if HAVE_RAW_DECL_WCSWIDTH
1280_GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1281 "use gnulib module wcswidth for portability");
1282# endif
1283#endif
1284
1285
c0c3707f
CB
1286/* Convert *TP to a date and time wide string. See
1287 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
1288#if @GNULIB_WCSFTIME@
1289# if @REPLACE_WCSFTIME@
1290# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1291# undef wcsftime
1292# define wcsftime rpl_wcsftime
1293# endif
698be2d8
CB
1294_GL_FUNCDECL_RPL (wcsftime, size_t,
1295 (wchar_t *restrict __buf, size_t __bufsize,
1296 const wchar_t *restrict __fmt,
1297 const struct tm *restrict __tp)
1298 _GL_ARG_NONNULL ((1, 3, 4)));
1299_GL_CXXALIAS_RPL (wcsftime, size_t,
1300 (wchar_t *restrict __buf, size_t __bufsize,
1301 const wchar_t *restrict __fmt,
1302 const struct tm *restrict __tp));
c0c3707f
CB
1303# else
1304# if !@HAVE_WCSFTIME@
698be2d8
CB
1305_GL_FUNCDECL_SYS (wcsftime, size_t,
1306 (wchar_t *restrict __buf, size_t __bufsize,
1307 const wchar_t *restrict __fmt,
1308 const struct tm *restrict __tp)
1309 _GL_ARG_NONNULL ((1, 3, 4)));
c0c3707f 1310# endif
698be2d8
CB
1311_GL_CXXALIAS_SYS (wcsftime, size_t,
1312 (wchar_t *restrict __buf, size_t __bufsize,
1313 const wchar_t *restrict __fmt,
1314 const struct tm *restrict __tp));
c0c3707f
CB
1315# endif
1316# if __GLIBC__ >= 2
1317_GL_CXXALIASWARN (wcsftime);
1318# endif
1319#elif defined GNULIB_POSIXCHECK
1320# undef wcsftime
1321# if HAVE_RAW_DECL_WCSFTIME
1322_GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
1323 "use gnulib module wcsftime for portability");
1324# endif
1325#endif
1326
1327
8690e634
JK
1328#endif /* _@GUARD_PREFIX@_WCHAR_H */
1329#endif /* _@GUARD_PREFIX@_WCHAR_H */
1330#endif