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