Debian Codegraph @

lib/wchar.in.h

raw
1 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
2
3 Copyright (C) 2007-2025 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 _@GUARD_PREFIX@_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 /* The glibc 2.5 /usr/include/wchar.h defines __need_wint_t but never undefines
57 it. We need to do that here. */
58 #undef __need_wint_t
59
60 #else
61 /* Normal invocation convention. */
62
63 #ifndef _@GUARD_PREFIX@_WCHAR_H
64
65 #define _@GUARD_PREFIX@_ALREADY_INCLUDING_WCHAR_H
66
67 #if @HAVE_FEATURES_H@
68 # include <features.h> /* for __GLIBC__ */
69 #endif
70
71 /* In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
72 by <stddef.h>.
73 But avoid namespace pollution on glibc systems. */
74 #if !(defined __GLIBC__ && !defined __UCLIBC__)
75 # include <stddef.h>
76 #endif
77
78 /* Include the original <wchar.h> if it exists.
79 Some builds of uClibc lack it. */
80 /* The include_next requires a split double-inclusion guard. */
81 #if @HAVE_WCHAR_H@
82 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
83 #endif
84
85 #undef _@GUARD_PREFIX@_ALREADY_INCLUDING_WCHAR_H
86
87 #ifndef _@GUARD_PREFIX@_WCHAR_H
88 #define _@GUARD_PREFIX@_WCHAR_H
89
90 /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
91 _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
92 HAVE_RAW_DECL_*. */
93 #if !_GL_CONFIG_H_INCLUDED
94 #error "Please include config.h first."
95 #endif
96
97 /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
98 that can be freed by passing them as the Ith argument to the
99 function F. */
100 #ifndef _GL_ATTRIBUTE_DEALLOC
101 # if __GNUC__ >= 11 && !defined __clang__
102 # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
103 # else
104 # define _GL_ATTRIBUTE_DEALLOC(f, i)
105 # endif
106 #endif
107
108 /* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
109 can be freed via 'free'; it can be used only after declaring 'free'. */
110 /* Applies to: functions. Cannot be used on inline functions. */
111 #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
112 # if defined __cplusplus && defined __GNUC__ && !defined __clang__
113 /* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
114 # define _GL_ATTRIBUTE_DEALLOC_FREE \
115 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
116 # else
117 # define _GL_ATTRIBUTE_DEALLOC_FREE \
118 _GL_ATTRIBUTE_DEALLOC (free, 1)
119 # endif
120 #endif
121
122 /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
123 allocated memory. */
124 /* Applies to: functions. */
125 #ifndef _GL_ATTRIBUTE_MALLOC
126 # if __GNUC__ >= 3 || defined __clang__
127 # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
128 # else
129 # define _GL_ATTRIBUTE_MALLOC
130 # endif
131 #endif
132
133 /* The __attribute__ feature is available in gcc versions 2.5 and later.
134 The attribute __pure__ was added in gcc 2.96. */
135 #ifndef _GL_ATTRIBUTE_PURE
136 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
137 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
138 # else
139 # define _GL_ATTRIBUTE_PURE /* empty */
140 # endif
141 #endif
142
143 /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
144 */
145 #ifndef _GL_ATTRIBUTE_NOTHROW
146 # if defined __cplusplus
147 # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
148 # if __cplusplus >= 201103L
149 # define _GL_ATTRIBUTE_NOTHROW noexcept (true)
150 # else
151 # define _GL_ATTRIBUTE_NOTHROW throw ()
152 # endif
153 # else
154 # define _GL_ATTRIBUTE_NOTHROW
155 # endif
156 # else
157 # if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
158 # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
159 # else
160 # define _GL_ATTRIBUTE_NOTHROW
161 # endif
162 # endif
163 #endif
164
165 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
166
167 /* The definition of _GL_ARG_NONNULL is copied here. */
168
169 /* The definition of _GL_WARN_ON_USE is copied here. */
170
171
172 /* Define wint_t and WEOF. (Also done in wctype.in.h.) */
173 #if !@HAVE_WINT_T@ && !defined wint_t
174 # define wint_t int
175 # ifndef WEOF
176 # define WEOF -1
177 # endif
178 #else
179 /* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
180 <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
181 wint_t must be "unchanged by default argument promotions". Override it. */
182 # if @GNULIBHEADERS_OVERRIDE_WINT_T@
183 # if !GNULIB_defined_wint_t
184 # if @HAVE_CRTDEFS_H@
185 # include <crtdefs.h>
186 # else
187 # include <stddef.h>
188 # endif
189 typedef unsigned int rpl_wint_t;
190 # undef wint_t
191 # define wint_t rpl_wint_t
192 # define GNULIB_defined_wint_t 1
193 # endif
194 # endif
195 # ifndef WEOF
196 # define WEOF ((wint_t) -1)
197 # endif
198 #endif
199
200
201 /* Override mbstate_t if it is too small.
202 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
203 implementing mbrtowc for encodings like UTF-8.
204 On AIX, MSVC, and OpenBSD 6.0, mbrtowc needs to be overridden, but
205 mbstate_t exists and is large enough and overriding it would cause problems
206 in C++ mode. */
207 #if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
208 # if !GNULIB_defined_mbstate_t
209 # if !(defined _AIX || defined _MSC_VER || defined __OpenBSD__)
210 typedef int rpl_mbstate_t;
211 # undef mbstate_t
212 # define mbstate_t rpl_mbstate_t
213 # endif
214 # define GNULIB_defined_mbstate_t 1
215 # endif
216 #endif
217
218 /* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
219 been included yet. */
220 #if @GNULIB_FREE_POSIX@
221 # if (@REPLACE_FREE@ && !defined free \
222 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
223 /* We can't do '#define free rpl_free' here. */
224 # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
225 _GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW;
226 # else
227 _GL_EXTERN_C void rpl_free (void *);
228 # endif
229 # undef _GL_ATTRIBUTE_DEALLOC_FREE
230 # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
231 # else
232 # if defined _MSC_VER && !defined free
233 _GL_EXTERN_C
234 # if defined _DLL
235 __declspec (dllimport)
236 # endif
237 void __cdecl free (void *);
238 # else
239 # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
240 _GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
241 # else
242 _GL_EXTERN_C void free (void *);
243 # endif
244 # endif
245 # endif
246 #else
247 # if defined _MSC_VER && !defined free
248 _GL_EXTERN_C
249 # if defined _DLL
250 __declspec (dllimport)
251 # endif
252 void __cdecl free (void *);
253 # else
254 # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
255 _GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
256 # else
257 _GL_EXTERN_C void free (void *);
258 # endif
259 # endif
260 #endif
261
262
263 #if @GNULIB_MBSZERO@
264 /* Get memset(). */
265 # include <string.h>
266 #endif
267
268
269 /* Convert a single-byte character to a wide character. */
270 #if @GNULIB_BTOWC@
271 # if @REPLACE_BTOWC@
272 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
273 # undef btowc
274 # define btowc rpl_btowc
275 # endif
276 _GL_FUNCDECL_RPL (btowc, wint_t, (int c), _GL_ATTRIBUTE_PURE);
277 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
278 # else
279 # if !@HAVE_BTOWC@
280 _GL_FUNCDECL_SYS (btowc, wint_t, (int c), _GL_ATTRIBUTE_PURE);
281 # endif
282 /* Need to cast, because on mingw, the return type is 'unsigned short'. */
283 _GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c));
284 # endif
285 # if __GLIBC__ >= 2
286 _GL_CXXALIASWARN (btowc);
287 # endif
288 #elif defined GNULIB_POSIXCHECK
289 # undef btowc
290 # if HAVE_RAW_DECL_BTOWC
291 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
292 "use gnulib module btowc for portability");
293 # endif
294 #endif
295
296
297 /* Convert a wide character to a single-byte character. */
298 #if @GNULIB_WCTOB@
299 # if @REPLACE_WCTOB@
300 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
301 # undef wctob
302 # define wctob rpl_wctob
303 # endif
304 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc), _GL_ATTRIBUTE_PURE);
305 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
306 # else
307 # if !defined wctob && !@HAVE_DECL_WCTOB@
308 /* wctob is provided by gnulib, or wctob exists but is not declared. */
309 _GL_FUNCDECL_SYS (wctob, int, (wint_t wc), _GL_ATTRIBUTE_PURE);
310 # endif
311 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
312 # endif
313 # if __GLIBC__ >= 2
314 _GL_CXXALIASWARN (wctob);
315 # endif
316 #elif defined GNULIB_POSIXCHECK
317 # undef wctob
318 # if HAVE_RAW_DECL_WCTOB
319 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
320 "use gnulib module wctob for portability");
321 # endif
322 #endif
323
324
325 /* Test whether *PS is in an initial state. */
326 #if @GNULIB_MBSINIT@
327 # if @REPLACE_MBSINIT@
328 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
329 # undef mbsinit
330 # define mbsinit rpl_mbsinit
331 # endif
332 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps), );
333 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
334 # else
335 # if !@HAVE_MBSINIT@
336 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps), );
337 # endif
338 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
339 # endif
340 # if __GLIBC__ >= 2
341 _GL_CXXALIASWARN (mbsinit);
342 # endif
343 #elif defined GNULIB_POSIXCHECK
344 # undef mbsinit
345 # if HAVE_RAW_DECL_MBSINIT
346 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
347 "use gnulib module mbsinit for portability");
348 # endif
349 #endif
350
351
352 /* Put *PS into an initial state. */
353 #if @GNULIB_MBSZERO@
354 /* ISO C 23 § 7.31.6.(3) says that zeroing an mbstate_t is a way to put the
355 mbstate_t into an initial state. However, on many platforms an mbstate_t
356 is large, and it is possible - as an optimization - to get away with zeroing
357 only part of it. So, instead of
358
359 mbstate_t state = { 0 };
360
361 or
362
363 mbstate_t state;
364 memset (&state, 0, sizeof (mbstate_t));
365
366 we can write this faster code:
367
368 mbstate_t state;
369 mbszero (&state);
370 */
371 /* _GL_MBSTATE_INIT_SIZE describes how mbsinit() behaves: It is the number of
372 bytes at the beginning of an mbstate_t that need to be zero, for mbsinit()
373 to return true.
374 _GL_MBSTATE_ZERO_SIZE is the number of bytes at the beginning of an mbstate_t
375 that need to be zero,
376 - for mbsinit() to return true, and
377 - for all other multibyte-aware functions to operate properly.
378 0 < _GL_MBSTATE_INIT_SIZE <= _GL_MBSTATE_ZERO_SIZE <= sizeof (mbstate_t).
379 These values are determined by source code inspection, where possible, and
380 by running the gnulib unit tests.
381 We need _GL_MBSTATE_INIT_SIZE because if we define _GL_MBSTATE_ZERO_SIZE
382 without considering what mbsinit() does, we get test failures such as
383 assertion "mbsinit (&iter->state)" failed
384 */
385 # if GNULIB_defined_mbstate_t /* AIX, IRIX */
386 /* mbstate_t has at least 4 bytes. They are used as coded in
387 gnulib/lib/mbrtowc.c. */
388 # define _GL_MBSTATE_INIT_SIZE 1
389 /* define _GL_MBSTATE_ZERO_SIZE 4
390 does not work: it causes test failures.
391 So, use the safe fallback value, below. */
392 # elif __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 /* glibc */
393 /* mbstate_t is defined in <bits/types/__mbstate_t.h>.
394 For more details, see glibc/iconv/skeleton.c. */
395 # define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (((mbstate_t) {0}).__count) */
396 # define _GL_MBSTATE_ZERO_SIZE /* 8 */ sizeof (mbstate_t)
397 # elif defined MUSL_LIBC /* musl libc */
398 /* mbstate_t is defined in <bits/alltypes.h>.
399 It is an opaque aligned 8-byte struct, of which at most the first
400 4 bytes are used.
401 For more details, see src/multibyte/mbrtowc.c. */
402 # define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (unsigned) */
403 # define _GL_MBSTATE_ZERO_SIZE 4
404 # elif defined __APPLE__ && defined __MACH__ /* macOS */
405 /* On macOS, mbstate_t is defined in <machine/_types.h>.
406 It is an opaque aligned 128-byte struct, of which at most the first
407 12 bytes are used.
408 For more details, see the __mbsinit implementations in
409 Libc-<version>/locale/FreeBSD/
410 {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8,utf2}.c. */
411 /* File INIT_SIZE ZERO_SIZE
412 ascii.c 0 0
413 none.c 0 0
414 euc.c 12 12
415 mskanji.c 4 4
416 big5.c 4 4
417 gb2312.c 4 6
418 gbk.c 4 4
419 gb18030.c 4 8
420 utf8.c 8 10
421 utf2.c 8 12 */
422 # define _GL_MBSTATE_INIT_SIZE 12
423 # define _GL_MBSTATE_ZERO_SIZE 12
424 # elif defined __FreeBSD__ /* FreeBSD */
425 /* On FreeBSD, mbstate_t is defined in src/sys/sys/_types.h.
426 It is an opaque aligned 128-byte struct, of which at most the first
427 12 bytes are used.
428 For more details, see the __mbsinit implementations in
429 src/lib/libc/locale/
430 {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
431 /* File INIT_SIZE ZERO_SIZE
432 ascii.c 0 0
433 none.c 0 0
434 euc.c 12 12
435 mskanji.c 4 4
436 big5.c 4 4
437 gb2312.c 4 6
438 gbk.c 4 4
439 gb18030.c 4 8
440 utf8.c 8 12 */
441 # define _GL_MBSTATE_INIT_SIZE 12
442 # define _GL_MBSTATE_ZERO_SIZE 12
443 # elif defined __NetBSD__ /* NetBSD */
444 /* On NetBSD, mbstate_t is defined in src/sys/sys/ansi.h.
445 It is an opaque aligned 128-byte struct, of which at most the first
446 28 bytes are used.
447 For more details, see the *State types in
448 src/lib/libc/citrus/modules/citrus_*.c
449 (ignoring citrus_{hz,iso2022,utf7,viqr,zw}.c, since these implement
450 stateful encodings, not usable as locale encodings). */
451 /* File ZERO_SIZE
452 citrus/citrus_none.c 0
453 citrus/modules/citrus_euc.c 8
454 citrus/modules/citrus_euctw.c 8
455 citrus/modules/citrus_mskanji.c 8
456 citrus/modules/citrus_big5.c 8
457 citrus/modules/citrus_gbk2k.c 8
458 citrus/modules/citrus_dechanyu.c 8
459 citrus/modules/citrus_johab.c 6
460 citrus/modules/citrus_utf8.c 12 */
461 /* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
462 failures for values < 28. */
463 # define _GL_MBSTATE_ZERO_SIZE 28
464 # elif defined __OpenBSD__ /* OpenBSD */
465 /* On OpenBSD, mbstate_t is defined in src/sys/sys/_types.h.
466 It is an opaque aligned 128-byte struct, of which at most the first
467 12 bytes are used.
468 For more details, see src/lib/libc/citrus/citrus_*.c. */
469 /* File INIT_SIZE ZERO_SIZE
470 citrus_none.c 0 0
471 citrus_utf8.c 12 12 */
472 # define _GL_MBSTATE_INIT_SIZE 12
473 # define _GL_MBSTATE_ZERO_SIZE 12
474 # elif defined __minix /* Minix */
475 /* On Minix, mbstate_t is defined in sys/sys/ansi.h.
476 It is an opaque aligned 128-byte struct.
477 For more details, see the *State types in
478 lib/libc/citrus/citrus_*.c. */
479 /* File INIT_SIZE ZERO_SIZE
480 citrus_none.c 0 0 */
481 /* But 1 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
482 failures for values < 4. */
483 # define _GL_MBSTATE_ZERO_SIZE 4
484 # elif defined __sun /* Solaris */
485 /* On Solaris, mbstate_t is defined in <wchar_impl.h>.
486 It is an opaque aligned 24-byte or 32-byte struct, of which at most the first
487 20 or 28 bytes are used.
488 For more details on OpenSolaris derivatives, see the *State types in
489 illumos-gate/usr/src/lib/libc/port/locale/
490 {none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
491 /* File INIT_SIZE ZERO_SIZE
492 none.c 0 0
493 euc.c 12 12
494 mskanji.c 4 4
495 big5.c 4 4
496 gb2312.c 4 6
497 gbk.c 4 4
498 gb18030.c 4 8
499 utf8.c 12 12 */
500 /* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
501 failures
502 - in OpenIndiana and OmniOS: for values < 16,
503 - in Solaris 10 and 11: for values < 20 (in 32-bit mode)
504 or < 28 (in 64-bit mode).
505 Since we don't have a good way to distinguish the OpenSolaris derivatives
506 from the proprietary Solaris versions, and can't inspect the Solaris source
507 code, use the safe fallback values, below. */
508 # elif defined __CYGWIN__ /* Cygwin */
509 /* On Cygwin, mbstate_t is defined in <sys/_types.h>.
510 For more details, see newlib/libc/stdlib/mbtowc_r.c and
511 winsup/cygwin/strfuncs.cc. */
512 # define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (int) */
513 # define _GL_MBSTATE_ZERO_SIZE 8
514 # elif defined _WIN32 && !defined __CYGWIN__ /* Native Windows. */
515 /* MSVC defines 'mbstate_t' as an aligned 8-byte struct.
516 On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined
517 as an aligned 8-byte struct, of which the first 4 bytes matter.
518 Use the safe values, below. */
519 # elif defined __ANDROID__ /* Android */
520 /* Android defines 'mbstate_t' in <bits/mbstate_t.h>.
521 It is an opaque 4-byte or 8-byte struct.
522 For more details, see
523 bionic/libc/private/bionic_mbstate.h
524 bionic/libc/bionic/mbrtoc32.cpp
525 bionic/libc/bionic/mbrtoc16.cpp
526 */
527 # define _GL_MBSTATE_INIT_SIZE 4
528 # define _GL_MBSTATE_ZERO_SIZE 4
529 # endif
530 /* Use safe values as defaults. */
531 # ifndef _GL_MBSTATE_INIT_SIZE
532 # define _GL_MBSTATE_INIT_SIZE sizeof (mbstate_t)
533 # endif
534 # ifndef _GL_MBSTATE_ZERO_SIZE
535 # define _GL_MBSTATE_ZERO_SIZE sizeof (mbstate_t)
536 # endif
537 _GL_BEGIN_C_LINKAGE
538 # if !GNULIB_defined_mbszero
539 # if defined IN_MBSZERO
540 _GL_EXTERN_INLINE
541 # else
542 _GL_INLINE
543 # endif
544 _GL_ARG_NONNULL ((1)) void
545 mbszero (mbstate_t *ps)
546 {
547 memset (ps, 0, _GL_MBSTATE_ZERO_SIZE);
548 }
549 # define GNULIB_defined_mbszero 1
550 # endif
551 _GL_END_C_LINKAGE
552 _GL_CXXALIAS_SYS (mbszero, void, (mbstate_t *ps));
553 _GL_CXXALIASWARN (mbszero);
554 #endif
555
556
557 /* Convert a multibyte character to a wide character. */
558 #if @GNULIB_MBRTOWC@
559 # if @REPLACE_MBRTOWC@
560 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
561 # undef mbrtowc
562 # define mbrtowc rpl_mbrtowc
563 # endif
564 _GL_FUNCDECL_RPL (mbrtowc, size_t,
565 (wchar_t *restrict pwc, const char *restrict s, size_t n,
566 mbstate_t *restrict ps), );
567 _GL_CXXALIAS_RPL (mbrtowc, size_t,
568 (wchar_t *restrict pwc, const char *restrict s, size_t n,
569 mbstate_t *restrict ps));
570 # else
571 # if !@HAVE_MBRTOWC@
572 _GL_FUNCDECL_SYS (mbrtowc, size_t,
573 (wchar_t *restrict pwc, const char *restrict s, size_t n,
574 mbstate_t *restrict ps), );
575 # endif
576 _GL_CXXALIAS_SYS (mbrtowc, size_t,
577 (wchar_t *restrict pwc, const char *restrict s, size_t n,
578 mbstate_t *restrict ps));
579 # endif
580 # if __GLIBC__ >= 2
581 _GL_CXXALIASWARN (mbrtowc);
582 # endif
583 #elif defined GNULIB_POSIXCHECK
584 # undef mbrtowc
585 # if HAVE_RAW_DECL_MBRTOWC
586 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
587 "use gnulib module mbrtowc for portability");
588 # endif
589 #endif
590
591
592 /* Recognize a multibyte character. */
593 #if @GNULIB_MBRLEN@
594 # if @REPLACE_MBRLEN@
595 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
596 # undef mbrlen
597 # define mbrlen rpl_mbrlen
598 # endif
599 _GL_FUNCDECL_RPL (mbrlen, size_t,
600 (const char *restrict s, size_t n, mbstate_t *restrict ps), );
601 _GL_CXXALIAS_RPL (mbrlen, size_t,
602 (const char *restrict s, size_t n, mbstate_t *restrict ps));
603 # else
604 # if !@HAVE_MBRLEN@
605 _GL_FUNCDECL_SYS (mbrlen, size_t,
606 (const char *restrict s, size_t n, mbstate_t *restrict ps), );
607 # endif
608 _GL_CXXALIAS_SYS (mbrlen, size_t,
609 (const char *restrict s, size_t n, mbstate_t *restrict ps));
610 # endif
611 # if __GLIBC__ >= 2
612 _GL_CXXALIASWARN (mbrlen);
613 # endif
614 #elif defined GNULIB_POSIXCHECK
615 # undef mbrlen
616 # if HAVE_RAW_DECL_MBRLEN
617 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
618 "use gnulib module mbrlen for portability");
619 # endif
620 #endif
621
622
623 /* Convert a string to a wide string. */
624 #if @GNULIB_MBSRTOWCS@
625 # if @REPLACE_MBSRTOWCS@
626 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
627 # undef mbsrtowcs
628 # define mbsrtowcs rpl_mbsrtowcs
629 # endif
630 _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
631 (wchar_t *restrict dest,
632 const char **restrict srcp, size_t len,
633 mbstate_t *restrict ps),
634 _GL_ARG_NONNULL ((2)));
635 _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
636 (wchar_t *restrict dest,
637 const char **restrict srcp, size_t len,
638 mbstate_t *restrict ps));
639 # else
640 # if !@HAVE_MBSRTOWCS@
641 _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
642 (wchar_t *restrict dest,
643 const char **restrict srcp, size_t len,
644 mbstate_t *restrict ps),
645 _GL_ARG_NONNULL ((2)));
646 # endif
647 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
648 (wchar_t *restrict dest,
649 const char **restrict srcp, size_t len,
650 mbstate_t *restrict ps));
651 # endif
652 # if __GLIBC__ >= 2
653 _GL_CXXALIASWARN (mbsrtowcs);
654 # endif
655 #elif defined GNULIB_POSIXCHECK
656 # undef mbsrtowcs
657 # if HAVE_RAW_DECL_MBSRTOWCS
658 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
659 "use gnulib module mbsrtowcs for portability");
660 # endif
661 #endif
662
663
664 /* Convert a string to a wide string. */
665 #if @GNULIB_MBSNRTOWCS@
666 # if @REPLACE_MBSNRTOWCS@
667 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
668 # undef mbsnrtowcs
669 # define mbsnrtowcs rpl_mbsnrtowcs
670 # endif
671 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
672 (wchar_t *restrict dest,
673 const char **restrict srcp, size_t srclen, size_t len,
674 mbstate_t *restrict ps),
675 _GL_ARG_NONNULL ((2)));
676 _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
677 (wchar_t *restrict dest,
678 const char **restrict srcp, size_t srclen, size_t len,
679 mbstate_t *restrict ps));
680 # else
681 # if !@HAVE_MBSNRTOWCS@
682 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
683 (wchar_t *restrict dest,
684 const char **restrict srcp, size_t srclen, size_t len,
685 mbstate_t *restrict ps),
686 _GL_ARG_NONNULL ((2)));
687 # endif
688 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
689 (wchar_t *restrict dest,
690 const char **restrict srcp, size_t srclen, size_t len,
691 mbstate_t *restrict ps));
692 # endif
693 # if __GLIBC__ >= 2
694 _GL_CXXALIASWARN (mbsnrtowcs);
695 # endif
696 #elif defined GNULIB_POSIXCHECK
697 # undef mbsnrtowcs
698 # if HAVE_RAW_DECL_MBSNRTOWCS
699 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
700 "use gnulib module mbsnrtowcs for portability");
701 # endif
702 #endif
703
704
705 /* Convert a wide character to a multibyte character. */
706 #if @GNULIB_WCRTOMB@
707 # if @REPLACE_WCRTOMB@
708 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
709 # undef wcrtomb
710 # define wcrtomb rpl_wcrtomb
711 # endif
712 _GL_FUNCDECL_RPL (wcrtomb, size_t,
713 (char *restrict s, wchar_t wc, mbstate_t *restrict ps), );
714 _GL_CXXALIAS_RPL (wcrtomb, size_t,
715 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
716 # else
717 # if !@HAVE_WCRTOMB@
718 _GL_FUNCDECL_SYS (wcrtomb, size_t,
719 (char *restrict s, wchar_t wc, mbstate_t *restrict ps), );
720 # endif
721 _GL_CXXALIAS_SYS (wcrtomb, size_t,
722 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
723 # endif
724 # if __GLIBC__ >= 2
725 _GL_CXXALIASWARN (wcrtomb);
726 # endif
727 #elif defined GNULIB_POSIXCHECK
728 # undef wcrtomb
729 # if HAVE_RAW_DECL_WCRTOMB
730 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
731 "use gnulib module wcrtomb for portability");
732 # endif
733 #endif
734
735
736 /* Convert a wide string to a string. */
737 #if @GNULIB_WCSRTOMBS@
738 # if @REPLACE_WCSRTOMBS@
739 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
740 # undef wcsrtombs
741 # define wcsrtombs rpl_wcsrtombs
742 # endif
743 _GL_FUNCDECL_RPL (wcsrtombs, size_t,
744 (char *restrict dest, const wchar_t **restrict srcp,
745 size_t len,
746 mbstate_t *restrict ps),
747 _GL_ARG_NONNULL ((2)));
748 _GL_CXXALIAS_RPL (wcsrtombs, size_t,
749 (char *restrict dest, const wchar_t **restrict srcp,
750 size_t len,
751 mbstate_t *restrict ps));
752 # else
753 # if !@HAVE_WCSRTOMBS@
754 _GL_FUNCDECL_SYS (wcsrtombs, size_t,
755 (char *restrict dest, const wchar_t **restrict srcp,
756 size_t len,
757 mbstate_t *restrict ps),
758 _GL_ARG_NONNULL ((2)));
759 # endif
760 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
761 (char *restrict dest, const wchar_t **restrict srcp,
762 size_t len,
763 mbstate_t *restrict ps));
764 # endif
765 # if __GLIBC__ >= 2
766 _GL_CXXALIASWARN (wcsrtombs);
767 # endif
768 #elif defined GNULIB_POSIXCHECK
769 # undef wcsrtombs
770 # if HAVE_RAW_DECL_WCSRTOMBS
771 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
772 "use gnulib module wcsrtombs for portability");
773 # endif
774 #endif
775
776
777 /* Convert a wide string to a string. */
778 #if @GNULIB_WCSNRTOMBS@
779 # if @REPLACE_WCSNRTOMBS@
780 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
781 # undef wcsnrtombs
782 # define wcsnrtombs rpl_wcsnrtombs
783 # endif
784 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
785 (char *restrict dest,
786 const wchar_t **restrict srcp, size_t srclen,
787 size_t len,
788 mbstate_t *restrict ps),
789 _GL_ARG_NONNULL ((2)));
790 _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
791 (char *restrict dest,
792 const wchar_t **restrict srcp, size_t srclen,
793 size_t len,
794 mbstate_t *restrict ps));
795 # else
796 # if !@HAVE_WCSNRTOMBS@ || (defined __cplusplus && defined __sun)
797 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
798 (char *restrict dest,
799 const wchar_t **restrict srcp, size_t srclen,
800 size_t len,
801 mbstate_t *restrict ps),
802 _GL_ARG_NONNULL ((2)));
803 # endif
804 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
805 (char *restrict dest,
806 const wchar_t **restrict srcp, size_t srclen,
807 size_t len,
808 mbstate_t *restrict ps));
809 # endif
810 # if __GLIBC__ >= 2
811 _GL_CXXALIASWARN (wcsnrtombs);
812 # endif
813 #elif defined GNULIB_POSIXCHECK
814 # undef wcsnrtombs
815 # if HAVE_RAW_DECL_WCSNRTOMBS
816 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
817 "use gnulib module wcsnrtombs for portability");
818 # endif
819 #endif
820
821
822 /* Return the number of screen columns needed for WC. */
823 #if @GNULIB_WCWIDTH@
824 # if @REPLACE_WCWIDTH@
825 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
826 # undef wcwidth
827 # define wcwidth rpl_wcwidth
828 # endif
829 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t), _GL_ATTRIBUTE_PURE);
830 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
831 # else
832 # if !@HAVE_DECL_WCWIDTH@
833 /* wcwidth exists but is not declared. */
834 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t), _GL_ATTRIBUTE_PURE);
835 # endif
836 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
837 # endif
838 # if __GLIBC__ >= 2
839 _GL_CXXALIASWARN (wcwidth);
840 # endif
841 #elif defined GNULIB_POSIXCHECK
842 # undef wcwidth
843 # if HAVE_RAW_DECL_WCWIDTH
844 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
845 "use gnulib module wcwidth for portability");
846 # endif
847 #endif
848
849
850 /* Search N wide characters of S for C. */
851 #if @GNULIB_WMEMCHR@
852 # if !@HAVE_WMEMCHR@
853 _GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n),
854 _GL_ATTRIBUTE_PURE);
855 # endif
856 /* On some systems, this function is defined as an overloaded function:
857 extern "C++" {
858 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
859 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
860 } */
861 _GL_CXXALIAS_SYS_CAST2 (wmemchr,
862 wchar_t *, (const wchar_t *, wchar_t, size_t),
863 const wchar_t *, (const wchar_t *, wchar_t, size_t));
864 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
865 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
866 && !defined __clang__
867 _GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
868 _GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
869 (const wchar_t *s, wchar_t c, size_t n));
870 # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
871 _GL_CXXALIASWARN (wmemchr);
872 # endif
873 #elif defined GNULIB_POSIXCHECK
874 # undef wmemchr
875 # if HAVE_RAW_DECL_WMEMCHR
876 _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
877 "use gnulib module wmemchr for portability");
878 # endif
879 #endif
880
881
882 /* Compare N wide characters of S1 and S2. */
883 #if @GNULIB_WMEMCMP@
884 # if @REPLACE_WMEMCMP@
885 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
886 # undef wmemcmp
887 # define wmemcmp rpl_wmemcmp
888 # endif
889 _GL_FUNCDECL_RPL (wmemcmp, int,
890 (const wchar_t *s1, const wchar_t *s2, size_t n),
891 _GL_ATTRIBUTE_PURE);
892 _GL_CXXALIAS_RPL (wmemcmp, int,
893 (const wchar_t *s1, const wchar_t *s2, size_t n));
894 # else
895 # if !@HAVE_WMEMCMP@
896 _GL_FUNCDECL_SYS (wmemcmp, int,
897 (const wchar_t *s1, const wchar_t *s2, size_t n),
898 _GL_ATTRIBUTE_PURE);
899 # endif
900 _GL_CXXALIAS_SYS (wmemcmp, int,
901 (const wchar_t *s1, const wchar_t *s2, size_t n));
902 # endif
903 # if __GLIBC__ >= 2
904 _GL_CXXALIASWARN (wmemcmp);
905 # endif
906 #elif defined GNULIB_POSIXCHECK
907 # undef wmemcmp
908 # if HAVE_RAW_DECL_WMEMCMP
909 _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
910 "use gnulib module wmemcmp for portability");
911 # endif
912 #endif
913
914
915 /* Copy N wide characters of SRC to DEST. */
916 #if @GNULIB_WMEMCPY@
917 # if !@HAVE_WMEMCPY@
918 _GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
919 (wchar_t *restrict dest,
920 const wchar_t *restrict src, size_t n), );
921 # endif
922 _GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
923 (wchar_t *restrict dest,
924 const wchar_t *restrict src, size_t n));
925 # if __GLIBC__ >= 2
926 _GL_CXXALIASWARN (wmemcpy);
927 # endif
928 #elif defined GNULIB_POSIXCHECK
929 # undef wmemcpy
930 # if HAVE_RAW_DECL_WMEMCPY
931 _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
932 "use gnulib module wmemcpy for portability");
933 # endif
934 #endif
935
936
937 /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
938 overlapping memory areas. */
939 #if @GNULIB_WMEMMOVE@
940 # if !@HAVE_WMEMMOVE@
941 _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
942 (wchar_t *dest, const wchar_t *src, size_t n), );
943 # endif
944 _GL_CXXALIAS_SYS (wmemmove, wchar_t *,
945 (wchar_t *dest, const wchar_t *src, size_t n));
946 # if __GLIBC__ >= 2
947 _GL_CXXALIASWARN (wmemmove);
948 # endif
949 #elif defined GNULIB_POSIXCHECK
950 # undef wmemmove
951 # if HAVE_RAW_DECL_WMEMMOVE
952 _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
953 "use gnulib module wmemmove for portability");
954 # endif
955 #endif
956
957
958 /* Copy N wide characters of SRC to DEST.
959 Return pointer to wide characters after the last written wide character. */
960 #if @GNULIB_WMEMPCPY@
961 # if @REPLACE_WMEMPCPY@
962 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
963 # undef wmempcpy
964 # define wmempcpy rpl_wmempcpy
965 # endif
966 _GL_FUNCDECL_RPL (wmempcpy, wchar_t *,
967 (wchar_t *restrict dest,
968 const wchar_t *restrict src, size_t n), );
969 _GL_CXXALIAS_RPL (wmempcpy, wchar_t *,
970 (wchar_t *restrict dest,
971 const wchar_t *restrict src, size_t n));
972 # else
973 # if !@HAVE_WMEMPCPY@
974 _GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
975 (wchar_t *restrict dest,
976 const wchar_t *restrict src, size_t n), );
977 # endif
978 _GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
979 (wchar_t *restrict dest,
980 const wchar_t *restrict src, size_t n));
981 # endif
982 # if __GLIBC__ >= 2
983 _GL_CXXALIASWARN (wmempcpy);
984 # endif
985 #elif defined GNULIB_POSIXCHECK
986 # undef wmempcpy
987 # if HAVE_RAW_DECL_WMEMPCPY
988 _GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
989 "use gnulib module wmempcpy for portability");
990 # endif
991 #endif
992
993
994 /* Set N wide characters of S to C. */
995 #if @GNULIB_WMEMSET@
996 # if !@HAVE_WMEMSET@
997 _GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n), );
998 # endif
999 _GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
1000 # if __GLIBC__ >= 2
1001 _GL_CXXALIASWARN (wmemset);
1002 # endif
1003 #elif defined GNULIB_POSIXCHECK
1004 # undef wmemset
1005 # if HAVE_RAW_DECL_WMEMSET
1006 _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
1007 "use gnulib module wmemset for portability");
1008 # endif
1009 #endif
1010
1011
1012 /* Return the number of wide characters in S. */
1013 #if @GNULIB_WCSLEN@
1014 # if !@HAVE_WCSLEN@
1015 _GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s), _GL_ATTRIBUTE_PURE);
1016 # endif
1017 _GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
1018 # if __GLIBC__ >= 2
1019 _GL_CXXALIASWARN (wcslen);
1020 # endif
1021 #elif defined GNULIB_POSIXCHECK
1022 # undef wcslen
1023 # if HAVE_RAW_DECL_WCSLEN
1024 _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
1025 "use gnulib module wcslen for portability");
1026 # endif
1027 #endif
1028
1029
1030 /* Return the number of wide characters in S, but at most MAXLEN. */
1031 #if @GNULIB_WCSNLEN@
1032 /* On Solaris 11.3, the header files declare the function in the std::
1033 namespace, not in the global namespace. So, force a declaration in
1034 the global namespace. */
1035 # if !@HAVE_WCSNLEN@ || (defined __sun && defined __cplusplus)
1036 _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen),
1037 _GL_ATTRIBUTE_PURE);
1038 # endif
1039 _GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
1040 _GL_CXXALIASWARN (wcsnlen);
1041 #elif defined GNULIB_POSIXCHECK
1042 # undef wcsnlen
1043 # if HAVE_RAW_DECL_WCSNLEN
1044 _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
1045 "use gnulib module wcsnlen for portability");
1046 # endif
1047 #endif
1048
1049
1050 /* Copy SRC to DEST. */
1051 #if @GNULIB_WCSCPY@
1052 # if !@HAVE_WCSCPY@
1053 _GL_FUNCDECL_SYS (wcscpy, wchar_t *,
1054 (wchar_t *restrict dest, const wchar_t *restrict src), );
1055 # endif
1056 _GL_CXXALIAS_SYS (wcscpy, wchar_t *,
1057 (wchar_t *restrict dest, const wchar_t *restrict src));
1058 # if __GLIBC__ >= 2
1059 _GL_CXXALIASWARN (wcscpy);
1060 # endif
1061 #elif defined GNULIB_POSIXCHECK
1062 # undef wcscpy
1063 # if HAVE_RAW_DECL_WCSCPY
1064 _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
1065 "use gnulib module wcscpy for portability");
1066 # endif
1067 #endif
1068
1069
1070 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
1071 #if @GNULIB_WCPCPY@
1072 /* On Solaris 11.3, the header files declare the function in the std::
1073 namespace, not in the global namespace. So, force a declaration in
1074 the global namespace. */
1075 # if !@HAVE_WCPCPY@ || (defined __sun && defined __cplusplus)
1076 _GL_FUNCDECL_SYS (wcpcpy, wchar_t *,
1077 (wchar_t *restrict dest, const wchar_t *restrict src), );
1078 # endif
1079 _GL_CXXALIAS_SYS (wcpcpy, wchar_t *,
1080 (wchar_t *restrict dest, const wchar_t *restrict src));
1081 _GL_CXXALIASWARN (wcpcpy);
1082 #elif defined GNULIB_POSIXCHECK
1083 # undef wcpcpy
1084 # if HAVE_RAW_DECL_WCPCPY
1085 _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
1086 "use gnulib module wcpcpy for portability");
1087 # endif
1088 #endif
1089
1090
1091 /* Copy no more than N wide characters of SRC to DEST. */
1092 #if @GNULIB_WCSNCPY@
1093 # if !@HAVE_WCSNCPY@
1094 _GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
1095 (wchar_t *restrict dest,
1096 const wchar_t *restrict src, size_t n), );
1097 # endif
1098 _GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
1099 (wchar_t *restrict dest,
1100 const wchar_t *restrict src, size_t n));
1101 # if __GLIBC__ >= 2
1102 _GL_CXXALIASWARN (wcsncpy);
1103 # endif
1104 #elif defined GNULIB_POSIXCHECK
1105 # undef wcsncpy
1106 # if HAVE_RAW_DECL_WCSNCPY
1107 _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
1108 "use gnulib module wcsncpy for portability");
1109 # endif
1110 #endif
1111
1112
1113 /* Copy no more than N characters of SRC to DEST, returning the address of
1114 the last character written into DEST. */
1115 #if @GNULIB_WCPNCPY@
1116 /* On Solaris 11.3, the header files declare the function in the std::
1117 namespace, not in the global namespace. So, force a declaration in
1118 the global namespace. */
1119 # if !@HAVE_WCPNCPY@ || (defined __sun && defined __cplusplus)
1120 _GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
1121 (wchar_t *restrict dest,
1122 const wchar_t *restrict src, size_t n), );
1123 # endif
1124 _GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
1125 (wchar_t *restrict dest,
1126 const wchar_t *restrict src, size_t n));
1127 _GL_CXXALIASWARN (wcpncpy);
1128 #elif defined GNULIB_POSIXCHECK
1129 # undef wcpncpy
1130 # if HAVE_RAW_DECL_WCPNCPY
1131 _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
1132 "use gnulib module wcpncpy for portability");
1133 # endif
1134 #endif
1135
1136
1137 /* Append SRC onto DEST. */
1138 #if @GNULIB_WCSCAT@
1139 # if !@HAVE_WCSCAT@
1140 _GL_FUNCDECL_SYS (wcscat, wchar_t *,
1141 (wchar_t *restrict dest, const wchar_t *restrict src), );
1142 # endif
1143 _GL_CXXALIAS_SYS (wcscat, wchar_t *,
1144 (wchar_t *restrict dest, const wchar_t *restrict src));
1145 # if __GLIBC__ >= 2
1146 _GL_CXXALIASWARN (wcscat);
1147 # endif
1148 #elif defined GNULIB_POSIXCHECK
1149 # undef wcscat
1150 # if HAVE_RAW_DECL_WCSCAT
1151 _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
1152 "use gnulib module wcscat for portability");
1153 # endif
1154 #endif
1155
1156
1157 /* Append no more than N wide characters of SRC onto DEST. */
1158 #if @GNULIB_WCSNCAT@
1159 # if @REPLACE_WCSNCAT@
1160 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1161 # undef wcsncat
1162 # define wcsncat rpl_wcsncat
1163 # endif
1164 _GL_FUNCDECL_RPL (wcsncat, wchar_t *,
1165 (wchar_t *restrict dest, const wchar_t *restrict src,
1166 size_t n), );
1167 _GL_CXXALIAS_RPL (wcsncat, wchar_t *,
1168 (wchar_t *restrict dest, const wchar_t *restrict src,
1169 size_t n));
1170 # else
1171 # if !@HAVE_WCSNCAT@
1172 _GL_FUNCDECL_SYS (wcsncat, wchar_t *,
1173 (wchar_t *restrict dest, const wchar_t *restrict src,
1174 size_t n), );
1175 # endif
1176 _GL_CXXALIAS_SYS (wcsncat, wchar_t *,
1177 (wchar_t *restrict dest, const wchar_t *restrict src,
1178 size_t n));
1179 # endif
1180 # if __GLIBC__ >= 2
1181 _GL_CXXALIASWARN (wcsncat);
1182 # endif
1183 #elif defined GNULIB_POSIXCHECK
1184 # undef wcsncat
1185 # if HAVE_RAW_DECL_WCSNCAT
1186 _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
1187 "use gnulib module wcsncat for portability");
1188 # endif
1189 #endif
1190
1191
1192 /* Compare S1 and S2. */
1193 #if @GNULIB_WCSCMP@
1194 # if @REPLACE_WCSCMP@
1195 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1196 # undef wcscmp
1197 # define wcscmp rpl_wcscmp
1198 # endif
1199 _GL_FUNCDECL_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2),
1200 _GL_ATTRIBUTE_PURE);
1201 _GL_CXXALIAS_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
1202 # else
1203 # if !@HAVE_WCSCMP@
1204 _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2),
1205 _GL_ATTRIBUTE_PURE);
1206 # endif
1207 _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
1208 # endif
1209 # if __GLIBC__ >= 2
1210 _GL_CXXALIASWARN (wcscmp);
1211 # endif
1212 #elif defined GNULIB_POSIXCHECK
1213 # undef wcscmp
1214 # if HAVE_RAW_DECL_WCSCMP
1215 _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
1216 "use gnulib module wcscmp for portability");
1217 # endif
1218 #endif
1219
1220
1221 /* Compare no more than N wide characters of S1 and S2. */
1222 #if @GNULIB_WCSNCMP@
1223 # if @REPLACE_WCSNCMP@
1224 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1225 # undef wcsncmp
1226 # define wcsncmp rpl_wcsncmp
1227 # endif
1228 _GL_FUNCDECL_RPL (wcsncmp, int,
1229 (const wchar_t *s1, const wchar_t *s2, size_t n),
1230 _GL_ATTRIBUTE_PURE);
1231 _GL_CXXALIAS_RPL (wcsncmp, int,
1232 (const wchar_t *s1, const wchar_t *s2, size_t n));
1233 # else
1234 # if !@HAVE_WCSNCMP@
1235 _GL_FUNCDECL_SYS (wcsncmp, int,
1236 (const wchar_t *s1, const wchar_t *s2, size_t n),
1237 _GL_ATTRIBUTE_PURE);
1238 # endif
1239 _GL_CXXALIAS_SYS (wcsncmp, int,
1240 (const wchar_t *s1, const wchar_t *s2, size_t n));
1241 # endif
1242 # if __GLIBC__ >= 2
1243 _GL_CXXALIASWARN (wcsncmp);
1244 # endif
1245 #elif defined GNULIB_POSIXCHECK
1246 # undef wcsncmp
1247 # if HAVE_RAW_DECL_WCSNCMP
1248 _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
1249 "use gnulib module wcsncmp for portability");
1250 # endif
1251 #endif
1252
1253
1254 /* Compare S1 and S2, ignoring case. */
1255 #if @GNULIB_WCSCASECMP@
1256 /* On Solaris 11.3, the header files declare the function in the std::
1257 namespace, not in the global namespace. So, force a declaration in
1258 the global namespace. */
1259 # if !@HAVE_WCSCASECMP@ || (defined __sun && defined __cplusplus)
1260 _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2),
1261 _GL_ATTRIBUTE_PURE);
1262 # endif
1263 _GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
1264 _GL_CXXALIASWARN (wcscasecmp);
1265 #elif defined GNULIB_POSIXCHECK
1266 # undef wcscasecmp
1267 # if HAVE_RAW_DECL_WCSCASECMP
1268 _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
1269 "use gnulib module wcscasecmp for portability");
1270 # endif
1271 #endif
1272
1273
1274 /* Compare no more than N chars of S1 and S2, ignoring case. */
1275 #if @GNULIB_WCSNCASECMP@
1276 /* On Solaris 11.3, the header files declare the function in the std::
1277 namespace, not in the global namespace. So, force a declaration in
1278 the global namespace. */
1279 # if !@HAVE_WCSNCASECMP@ || (defined __sun && defined __cplusplus)
1280 _GL_FUNCDECL_SYS (wcsncasecmp, int,
1281 (const wchar_t *s1, const wchar_t *s2, size_t n),
1282 _GL_ATTRIBUTE_PURE);
1283 # endif
1284 _GL_CXXALIAS_SYS (wcsncasecmp, int,
1285 (const wchar_t *s1, const wchar_t *s2, size_t n));
1286 _GL_CXXALIASWARN (wcsncasecmp);
1287 #elif defined GNULIB_POSIXCHECK
1288 # undef wcsncasecmp
1289 # if HAVE_RAW_DECL_WCSNCASECMP
1290 _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
1291 "use gnulib module wcsncasecmp for portability");
1292 # endif
1293 #endif
1294
1295
1296 /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
1297 category of the current locale. */
1298 #if @GNULIB_WCSCOLL@
1299 # if !@HAVE_WCSCOLL@
1300 _GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2), );
1301 # endif
1302 _GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
1303 # if __GLIBC__ >= 2
1304 _GL_CXXALIASWARN (wcscoll);
1305 # endif
1306 #elif defined GNULIB_POSIXCHECK
1307 # undef wcscoll
1308 # if HAVE_RAW_DECL_WCSCOLL
1309 _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
1310 "use gnulib module wcscoll for portability");
1311 # endif
1312 #endif
1313
1314
1315 /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
1316 to two transformed strings the result is the as applying 'wcscoll' to the
1317 original strings. */
1318 #if @GNULIB_WCSXFRM@
1319 # if !@HAVE_WCSXFRM@
1320 _GL_FUNCDECL_SYS (wcsxfrm, size_t,
1321 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n), );
1322 # endif
1323 _GL_CXXALIAS_SYS (wcsxfrm, size_t,
1324 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
1325 # if __GLIBC__ >= 2
1326 _GL_CXXALIASWARN (wcsxfrm);
1327 # endif
1328 #elif defined GNULIB_POSIXCHECK
1329 # undef wcsxfrm
1330 # if HAVE_RAW_DECL_WCSXFRM
1331 _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
1332 "use gnulib module wcsxfrm for portability");
1333 # endif
1334 #endif
1335
1336
1337 /* Duplicate S, returning an identical malloc'd string. */
1338 #if @GNULIB_WCSDUP@
1339 # if defined _WIN32 && !defined __CYGWIN__
1340 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1341 # undef wcsdup
1342 # define wcsdup _wcsdup
1343 # endif
1344 _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1345 # else
1346 /* On Solaris 11.3, the header files declare the function in the std::
1347 namespace, not in the global namespace. So, force a declaration in
1348 the global namespace. */
1349 # if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) \
1350 || (__GNUC__ >= 11 && !defined __clang__)
1351 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1352 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1353 (const wchar_t *s),
1354 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1355 _GL_ATTRIBUTE_NOTHROW;
1356 # else
1357 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1358 (const wchar_t *s),
1359 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1360 # endif
1361 # endif
1362 _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1363 # endif
1364 _GL_CXXALIASWARN (wcsdup);
1365 #else
1366 # if (__GNUC__ >= 11 && !defined __clang__) && !defined wcsdup
1367 /* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */
1368 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1369 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1370 (const wchar_t *s),
1371 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1372 _GL_ATTRIBUTE_NOTHROW;
1373 # else
1374 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1375 (const wchar_t *s),
1376 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1377 # endif
1378 # endif
1379 # if defined GNULIB_POSIXCHECK
1380 # undef wcsdup
1381 # if HAVE_RAW_DECL_WCSDUP
1382 _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
1383 "use gnulib module wcsdup for portability");
1384 # endif
1385 # elif @GNULIB_MDA_WCSDUP@
1386 /* On native Windows, map 'wcsdup' to '_wcsdup', so that -loldnames is not
1387 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1388 platforms by defining GNULIB_NAMESPACE::wcsdup always. */
1389 # if defined _WIN32 && !defined __CYGWIN__
1390 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1391 # undef wcsdup
1392 # define wcsdup _wcsdup
1393 # endif
1394 _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1395 # else
1396 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1397 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1398 (const wchar_t *s),
1399 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1400 _GL_ATTRIBUTE_NOTHROW;
1401 # else
1402 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1403 (const wchar_t *s),
1404 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1405 # endif
1406 # if @HAVE_DECL_WCSDUP@
1407 _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1408 # endif
1409 # endif
1410 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_WCSDUP@
1411 _GL_CXXALIASWARN (wcsdup);
1412 # endif
1413 # endif
1414 #endif
1415
1416
1417 /* Find the first occurrence of WC in WCS. */
1418 #if @GNULIB_WCSCHR@
1419 # if !@HAVE_WCSCHR@
1420 _GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc),
1421 _GL_ATTRIBUTE_PURE);
1422 # endif
1423 /* On some systems, this function is defined as an overloaded function:
1424 extern "C++" {
1425 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
1426 wchar_t * std::wcschr (wchar_t *, wchar_t);
1427 } */
1428 _GL_CXXALIAS_SYS_CAST2 (wcschr,
1429 wchar_t *, (const wchar_t *, wchar_t),
1430 const wchar_t *, (const wchar_t *, wchar_t));
1431 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1432 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1433 && !defined __clang__
1434 _GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
1435 _GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
1436 # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1437 _GL_CXXALIASWARN (wcschr);
1438 # endif
1439 #elif defined GNULIB_POSIXCHECK
1440 # undef wcschr
1441 # if HAVE_RAW_DECL_WCSCHR
1442 _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
1443 "use gnulib module wcschr for portability");
1444 # endif
1445 #endif
1446
1447
1448 /* Find the last occurrence of WC in WCS. */
1449 #if @GNULIB_WCSRCHR@
1450 # if !@HAVE_WCSRCHR@
1451 _GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc),
1452 _GL_ATTRIBUTE_PURE);
1453 # endif
1454 /* On some systems, this function is defined as an overloaded function:
1455 extern "C++" {
1456 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
1457 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
1458 } */
1459 _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
1460 wchar_t *, (const wchar_t *, wchar_t),
1461 const wchar_t *, (const wchar_t *, wchar_t));
1462 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1463 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1464 && !defined __clang__
1465 _GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
1466 _GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
1467 # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1468 _GL_CXXALIASWARN (wcsrchr);
1469 # endif
1470 #elif defined GNULIB_POSIXCHECK
1471 # undef wcsrchr
1472 # if HAVE_RAW_DECL_WCSRCHR
1473 _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
1474 "use gnulib module wcsrchr for portability");
1475 # endif
1476 #endif
1477
1478
1479 /* Return the length of the initial segment of WCS which consists entirely
1480 of wide characters not in REJECT. */
1481 #if @GNULIB_WCSCSPN@
1482 # if !@HAVE_WCSCSPN@
1483 _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject),
1484 _GL_ATTRIBUTE_PURE);
1485 # endif
1486 _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
1487 # if __GLIBC__ >= 2
1488 _GL_CXXALIASWARN (wcscspn);
1489 # endif
1490 #elif defined GNULIB_POSIXCHECK
1491 # undef wcscspn
1492 # if HAVE_RAW_DECL_WCSCSPN
1493 _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
1494 "use gnulib module wcscspn for portability");
1495 # endif
1496 #endif
1497
1498
1499 /* Return the length of the initial segment of WCS which consists entirely
1500 of wide characters in ACCEPT. */
1501 #if @GNULIB_WCSSPN@
1502 # if !@HAVE_WCSSPN@
1503 _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept),
1504 _GL_ATTRIBUTE_PURE);
1505 # endif
1506 _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
1507 # if __GLIBC__ >= 2
1508 _GL_CXXALIASWARN (wcsspn);
1509 # endif
1510 #elif defined GNULIB_POSIXCHECK
1511 # undef wcsspn
1512 # if HAVE_RAW_DECL_WCSSPN
1513 _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
1514 "use gnulib module wcsspn for portability");
1515 # endif
1516 #endif
1517
1518
1519 /* Find the first occurrence in WCS of any character in ACCEPT. */
1520 #if @GNULIB_WCSPBRK@
1521 # if !@HAVE_WCSPBRK@
1522 _GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
1523 (const wchar_t *wcs, const wchar_t *accept),
1524 _GL_ATTRIBUTE_PURE);
1525 # endif
1526 /* On some systems, this function is defined as an overloaded function:
1527 extern "C++" {
1528 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
1529 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
1530 } */
1531 _GL_CXXALIAS_SYS_CAST2 (wcspbrk,
1532 wchar_t *, (const wchar_t *, const wchar_t *),
1533 const wchar_t *, (const wchar_t *, const wchar_t *));
1534 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1535 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1536 && !defined __clang__
1537 _GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
1538 (wchar_t *wcs, const wchar_t *accept));
1539 _GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
1540 (const wchar_t *wcs, const wchar_t *accept));
1541 # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1542 _GL_CXXALIASWARN (wcspbrk);
1543 # endif
1544 #elif defined GNULIB_POSIXCHECK
1545 # undef wcspbrk
1546 # if HAVE_RAW_DECL_WCSPBRK
1547 _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
1548 "use gnulib module wcspbrk for portability");
1549 # endif
1550 #endif
1551
1552
1553 /* Find the first occurrence of NEEDLE in HAYSTACK. */
1554 #if @GNULIB_WCSSTR@
1555 # if @REPLACE_WCSSTR@
1556 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1557 # undef wcsstr
1558 # define wcsstr rpl_wcsstr
1559 # endif
1560 _GL_FUNCDECL_RPL (wcsstr, wchar_t *,
1561 (const wchar_t *restrict haystack,
1562 const wchar_t *restrict needle),
1563 _GL_ATTRIBUTE_PURE);
1564 _GL_CXXALIAS_RPL (wcsstr, wchar_t *,
1565 (const wchar_t *restrict haystack,
1566 const wchar_t *restrict needle));
1567 # else
1568 # if !@HAVE_WCSSTR@
1569 _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
1570 (const wchar_t *restrict haystack,
1571 const wchar_t *restrict needle),
1572 _GL_ATTRIBUTE_PURE);
1573 # endif
1574 /* On some systems, this function is defined as an overloaded function:
1575 extern "C++" {
1576 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
1577 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
1578 } */
1579 _GL_CXXALIAS_SYS_CAST2 (wcsstr,
1580 wchar_t *,
1581 (const wchar_t *restrict, const wchar_t *restrict),
1582 const wchar_t *,
1583 (const wchar_t *restrict, const wchar_t *restrict));
1584 # endif
1585 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1586 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1587 && !defined __clang__
1588 _GL_CXXALIASWARN1 (wcsstr, wchar_t *,
1589 (wchar_t *restrict haystack,
1590 const wchar_t *restrict needle));
1591 _GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
1592 (const wchar_t *restrict haystack,
1593 const wchar_t *restrict needle));
1594 # elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1595 _GL_CXXALIASWARN (wcsstr);
1596 # endif
1597 #elif defined GNULIB_POSIXCHECK
1598 # undef wcsstr
1599 # if HAVE_RAW_DECL_WCSSTR
1600 _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
1601 "use gnulib module wcsstr for portability");
1602 # endif
1603 #endif
1604
1605
1606 /* Divide WCS into tokens separated by characters in DELIM. */
1607 #if @GNULIB_WCSTOK@
1608 # if @REPLACE_WCSTOK@
1609 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1610 # undef wcstok
1611 # define wcstok rpl_wcstok
1612 # endif
1613 _GL_FUNCDECL_RPL (wcstok, wchar_t *,
1614 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1615 wchar_t **restrict ptr), );
1616 _GL_CXXALIAS_RPL (wcstok, wchar_t *,
1617 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1618 wchar_t **restrict ptr));
1619 # else
1620 # if !@HAVE_WCSTOK@
1621 _GL_FUNCDECL_SYS (wcstok, wchar_t *,
1622 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1623 wchar_t **restrict ptr), );
1624 # endif
1625 _GL_CXXALIAS_SYS (wcstok, wchar_t *,
1626 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1627 wchar_t **restrict ptr));
1628 # endif
1629 # if __GLIBC__ >= 2
1630 _GL_CXXALIASWARN (wcstok);
1631 # endif
1632 #elif defined GNULIB_POSIXCHECK
1633 # undef wcstok
1634 # if HAVE_RAW_DECL_WCSTOK
1635 _GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
1636 "use gnulib module wcstok for portability");
1637 # endif
1638 #endif
1639
1640
1641 /* Determine number of column positions required for first N wide
1642 characters (or fewer if S ends before this) in S. */
1643 #if @GNULIB_WCSWIDTH@
1644 # if @REPLACE_WCSWIDTH@
1645 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1646 # undef wcswidth
1647 # define wcswidth rpl_wcswidth
1648 # endif
1649 _GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n),
1650 _GL_ATTRIBUTE_PURE);
1651 _GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
1652 # else
1653 # if !@HAVE_WCSWIDTH@
1654 _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n),
1655 _GL_ATTRIBUTE_PURE);
1656 # endif
1657 _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
1658 # endif
1659 # if __GLIBC__ >= 2
1660 _GL_CXXALIASWARN (wcswidth);
1661 # endif
1662 #elif defined GNULIB_POSIXCHECK
1663 # undef wcswidth
1664 # if HAVE_RAW_DECL_WCSWIDTH
1665 _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1666 "use gnulib module wcswidth for portability");
1667 # endif
1668 #endif
1669
1670
1671 /* Convert *TP to a date and time wide string. See
1672 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
1673 #if @GNULIB_WCSFTIME@
1674 # if @REPLACE_WCSFTIME@
1675 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1676 # undef wcsftime
1677 # define wcsftime rpl_wcsftime
1678 # endif
1679 _GL_FUNCDECL_RPL (wcsftime, size_t,
1680 (wchar_t *restrict __buf, size_t __bufsize,
1681 const wchar_t *restrict __fmt,
1682 const struct tm *restrict __tp),
1683 _GL_ARG_NONNULL ((1, 3, 4)));
1684 _GL_CXXALIAS_RPL (wcsftime, size_t,
1685 (wchar_t *restrict __buf, size_t __bufsize,
1686 const wchar_t *restrict __fmt,
1687 const struct tm *restrict __tp));
1688 # else
1689 # if !@HAVE_WCSFTIME@
1690 _GL_FUNCDECL_SYS (wcsftime, size_t,
1691 (wchar_t *restrict __buf, size_t __bufsize,
1692 const wchar_t *restrict __fmt,
1693 const struct tm *restrict __tp),
1694 _GL_ARG_NONNULL ((1, 3, 4)));
1695 # endif
1696 _GL_CXXALIAS_SYS (wcsftime, size_t,
1697 (wchar_t *restrict __buf, size_t __bufsize,
1698 const wchar_t *restrict __fmt,
1699 const struct tm *restrict __tp));
1700 # endif
1701 # if __GLIBC__ >= 2
1702 _GL_CXXALIASWARN (wcsftime);
1703 # endif
1704 #elif defined GNULIB_POSIXCHECK
1705 # undef wcsftime
1706 # if HAVE_RAW_DECL_WCSFTIME
1707 _GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
1708 "use gnulib module wcsftime for portability");
1709 # endif
1710 #endif
1711
1712
1713 #if @GNULIB_WGETCWD@ && (defined _WIN32 && !defined __CYGWIN__)
1714 /* Gets the name of the current working directory.
1715 (a) If BUF is non-NULL, it is assumed to have room for SIZE wide characters.
1716 This function stores the working directory (NUL-terminated) in BUF and
1717 returns BUF.
1718 (b) If BUF is NULL, an array is allocated with 'malloc'. The array is SIZE
1719 wide characters long, unless SIZE == 0, in which case it is as big as
1720 necessary.
1721 If the directory couldn't be determined or SIZE was too small, this function
1722 returns NULL and sets errno. For a directory of length LEN, SIZE should be
1723 >= LEN + 3 in case (a) or >= LEN + 1 in case (b).
1724 Possible errno values include:
1725 - ERANGE if SIZE is too small.
1726 - ENOMEM if the memory could no be allocated. */
1727 _GL_FUNCDECL_SYS (wgetcwd, wchar_t *, (wchar_t *buf, size_t size), );
1728 #endif
1729
1730
1731 #endif /* _@GUARD_PREFIX@_WCHAR_H */
1732 #endif /* _@GUARD_PREFIX@_WCHAR_H */
1733 #endif