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