1 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
3 Copyright (C) 2007-2020 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 This program 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <https://www.gnu.org/licenses/>. */
18 /* Written by Eric Blake. */
21 * ISO C 99 <wchar.h> for platforms that have issues.
22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wchar.h.html>
24 * For now, this just ensures proper prerequisite inclusion order and
25 * the declaration of wcwidth().
29 @PRAGMA_SYSTEM_HEADER@
33 #if (((defined __need_mbstate_t || defined __need_wint_t) \
34 && !defined __MINGW32__) \
36 && ((defined _INTTYPES_INCLUDED \
37 && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \
38 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
39 || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
40 || defined _GL_ALREADY_INCLUDING_WCHAR_H)
41 /* Special invocation convention:
42 - Inside glibc and uClibc header files, but not MinGW.
43 - On HP-UX 11.00 we have a sequence of nested includes
44 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
45 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
46 and once directly. In both situations 'wint_t' is not yet defined,
47 therefore we cannot provide the function overrides; instead include only
48 the system's <wchar.h>.
49 - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of
50 <wchar.h> is actually processed, and that doesn't include 'mbstate_t'.
51 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
52 the latter includes <wchar.h>. But here, we have no way to detect whether
53 <wctype.h> is completely included or is still being included. */
55 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
58 /* Normal invocation convention. */
60 #ifndef _@GUARD_PREFIX@_WCHAR_H
62 #define _GL_ALREADY_INCLUDING_WCHAR_H
65 # include <features.h> /* for __GLIBC__ */
68 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
70 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
71 included before <wchar.h>.
72 In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
74 But avoid namespace pollution on glibc systems. */
75 #if !(defined __GLIBC__ && !defined __UCLIBC__)
83 /* Include the original <wchar.h> if it exists.
84 Some builds of uClibc lack it. */
85 /* The include_next requires a split double-inclusion guard. */
87 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
90 #undef _GL_ALREADY_INCLUDING_WCHAR_H
92 #ifndef _@GUARD_PREFIX@_WCHAR_H
93 #define _@GUARD_PREFIX@_WCHAR_H
95 /* The __attribute__ feature is available in gcc versions 2.5 and later.
96 The attribute __pure__ was added in gcc 2.96. */
97 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
98 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
100 # define _GL_ATTRIBUTE_PURE /* empty */
103 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
105 /* The definition of _GL_ARG_NONNULL is copied here. */
107 /* The definition of _GL_WARN_ON_USE is copied here. */
110 /* Define wint_t and WEOF. (Also done in wctype.in.h.) */
111 #if !@HAVE_WINT_T@ && !defined wint_t
117 /* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
118 <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
119 wint_t must be "unchanged by default argument promotions". Override it. */
120 # if @GNULIB_OVERRIDES_WINT_T@
121 # if !GNULIB_defined_wint_t
122 # if @HAVE_CRTDEFS_H@
123 # include <crtdefs.h>
127 typedef unsigned int rpl_wint_t
;
129 # define wint_t rpl_wint_t
130 # define GNULIB_defined_wint_t 1
134 # define WEOF ((wint_t) -1)
139 /* Override mbstate_t if it is too small.
140 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
141 implementing mbrtowc for encodings like UTF-8.
142 On AIX and MSVC, mbrtowc needs to be overridden, but mbstate_t exists and is
143 large enough and overriding it would cause problems in C++ mode. */
144 #if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
145 # if !GNULIB_defined_mbstate_t
146 # if !(defined _AIX || defined _MSC_VER)
147 typedef int rpl_mbstate_t
;
149 # define mbstate_t rpl_mbstate_t
151 # define GNULIB_defined_mbstate_t 1
156 /* Convert a single-byte character to a wide character. */
159 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
161 # define btowc rpl_btowc
163 _GL_FUNCDECL_RPL (btowc
, wint_t, (int c
) _GL_ATTRIBUTE_PURE
);
164 _GL_CXXALIAS_RPL (btowc
, wint_t, (int c
));
167 _GL_FUNCDECL_SYS (btowc
, wint_t, (int c
) _GL_ATTRIBUTE_PURE
);
169 /* Need to cast, because on mingw, the return type is 'unsigned short'. */
170 _GL_CXXALIAS_SYS_CAST (btowc
, wint_t, (int c
));
173 _GL_CXXALIASWARN (btowc
);
175 #elif defined GNULIB_POSIXCHECK
177 # if HAVE_RAW_DECL_BTOWC
178 _GL_WARN_ON_USE (btowc
, "btowc is unportable - "
179 "use gnulib module btowc for portability");
184 /* Convert a wide character to a single-byte character. */
187 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
189 # define wctob rpl_wctob
191 _GL_FUNCDECL_RPL (wctob
, int, (wint_t wc
) _GL_ATTRIBUTE_PURE
);
192 _GL_CXXALIAS_RPL (wctob
, int, (wint_t wc
));
194 # if !defined wctob && !@HAVE_DECL_WCTOB@
195 /* wctob is provided by gnulib, or wctob exists but is not declared. */
196 _GL_FUNCDECL_SYS (wctob
, int, (wint_t wc
) _GL_ATTRIBUTE_PURE
);
198 _GL_CXXALIAS_SYS (wctob
, int, (wint_t wc
));
201 _GL_CXXALIASWARN (wctob
);
203 #elif defined GNULIB_POSIXCHECK
205 # if HAVE_RAW_DECL_WCTOB
206 _GL_WARN_ON_USE (wctob
, "wctob is unportable - "
207 "use gnulib module wctob for portability");
212 /* Test whether *PS is in the initial state. */
214 # if @REPLACE_MBSINIT@
215 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
217 # define mbsinit rpl_mbsinit
219 _GL_FUNCDECL_RPL (mbsinit
, int, (const mbstate_t *ps
));
220 _GL_CXXALIAS_RPL (mbsinit
, int, (const mbstate_t *ps
));
223 _GL_FUNCDECL_SYS (mbsinit
, int, (const mbstate_t *ps
));
225 _GL_CXXALIAS_SYS (mbsinit
, int, (const mbstate_t *ps
));
228 _GL_CXXALIASWARN (mbsinit
);
230 #elif defined GNULIB_POSIXCHECK
232 # if HAVE_RAW_DECL_MBSINIT
233 _GL_WARN_ON_USE (mbsinit
, "mbsinit is unportable - "
234 "use gnulib module mbsinit for portability");
239 /* Convert a multibyte character to a wide character. */
241 # if @REPLACE_MBRTOWC@
242 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
244 # define mbrtowc rpl_mbrtowc
246 _GL_FUNCDECL_RPL (mbrtowc
, size_t,
247 (wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
));
248 _GL_CXXALIAS_RPL (mbrtowc
, size_t,
249 (wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
));
252 _GL_FUNCDECL_SYS (mbrtowc
, size_t,
253 (wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
));
255 _GL_CXXALIAS_SYS (mbrtowc
, size_t,
256 (wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
));
259 _GL_CXXALIASWARN (mbrtowc
);
261 #elif defined GNULIB_POSIXCHECK
263 # if HAVE_RAW_DECL_MBRTOWC
264 _GL_WARN_ON_USE (mbrtowc
, "mbrtowc is unportable - "
265 "use gnulib module mbrtowc for portability");
270 /* Recognize a multibyte character. */
272 # if @REPLACE_MBRLEN@
273 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
275 # define mbrlen rpl_mbrlen
277 _GL_FUNCDECL_RPL (mbrlen
, size_t, (const char *s
, size_t n
, mbstate_t *ps
));
278 _GL_CXXALIAS_RPL (mbrlen
, size_t, (const char *s
, size_t n
, mbstate_t *ps
));
281 _GL_FUNCDECL_SYS (mbrlen
, size_t, (const char *s
, size_t n
, mbstate_t *ps
));
283 _GL_CXXALIAS_SYS (mbrlen
, size_t, (const char *s
, size_t n
, mbstate_t *ps
));
286 _GL_CXXALIASWARN (mbrlen
);
288 #elif defined GNULIB_POSIXCHECK
290 # if HAVE_RAW_DECL_MBRLEN
291 _GL_WARN_ON_USE (mbrlen
, "mbrlen is unportable - "
292 "use gnulib module mbrlen for portability");
297 /* Convert a string to a wide string. */
298 #if @GNULIB_MBSRTOWCS@
299 # if @REPLACE_MBSRTOWCS@
300 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
302 # define mbsrtowcs rpl_mbsrtowcs
304 _GL_FUNCDECL_RPL (mbsrtowcs
, size_t,
305 (wchar_t *dest
, const char **srcp
, size_t len
, mbstate_t *ps
)
306 _GL_ARG_NONNULL ((2)));
307 _GL_CXXALIAS_RPL (mbsrtowcs
, size_t,
308 (wchar_t *dest
, const char **srcp
, size_t len
,
311 # if !@HAVE_MBSRTOWCS@
312 _GL_FUNCDECL_SYS (mbsrtowcs
, size_t,
313 (wchar_t *dest
, const char **srcp
, size_t len
, mbstate_t *ps
)
314 _GL_ARG_NONNULL ((2)));
316 _GL_CXXALIAS_SYS (mbsrtowcs
, size_t,
317 (wchar_t *dest
, const char **srcp
, size_t len
,
321 _GL_CXXALIASWARN (mbsrtowcs
);
323 #elif defined GNULIB_POSIXCHECK
325 # if HAVE_RAW_DECL_MBSRTOWCS
326 _GL_WARN_ON_USE (mbsrtowcs
, "mbsrtowcs is unportable - "
327 "use gnulib module mbsrtowcs for portability");
332 /* Convert a string to a wide string. */
333 #if @GNULIB_MBSNRTOWCS@
334 # if @REPLACE_MBSNRTOWCS@
335 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
337 # define mbsnrtowcs rpl_mbsnrtowcs
339 _GL_FUNCDECL_RPL (mbsnrtowcs
, size_t,
340 (wchar_t *dest
, const char **srcp
, size_t srclen
, size_t len
,
342 _GL_ARG_NONNULL ((2)));
343 _GL_CXXALIAS_RPL (mbsnrtowcs
, size_t,
344 (wchar_t *dest
, const char **srcp
, size_t srclen
, size_t len
,
347 # if !@HAVE_MBSNRTOWCS@
348 _GL_FUNCDECL_SYS (mbsnrtowcs
, size_t,
349 (wchar_t *dest
, const char **srcp
, size_t srclen
, size_t len
,
351 _GL_ARG_NONNULL ((2)));
353 _GL_CXXALIAS_SYS (mbsnrtowcs
, size_t,
354 (wchar_t *dest
, const char **srcp
, size_t srclen
, size_t len
,
357 _GL_CXXALIASWARN (mbsnrtowcs
);
358 #elif defined GNULIB_POSIXCHECK
360 # if HAVE_RAW_DECL_MBSNRTOWCS
361 _GL_WARN_ON_USE (mbsnrtowcs
, "mbsnrtowcs is unportable - "
362 "use gnulib module mbsnrtowcs for portability");
367 /* Convert a wide character to a multibyte character. */
369 # if @REPLACE_WCRTOMB@
370 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
372 # define wcrtomb rpl_wcrtomb
374 _GL_FUNCDECL_RPL (wcrtomb
, size_t, (char *s
, wchar_t wc
, mbstate_t *ps
));
375 _GL_CXXALIAS_RPL (wcrtomb
, size_t, (char *s
, wchar_t wc
, mbstate_t *ps
));
378 _GL_FUNCDECL_SYS (wcrtomb
, size_t, (char *s
, wchar_t wc
, mbstate_t *ps
));
380 _GL_CXXALIAS_SYS (wcrtomb
, size_t, (char *s
, wchar_t wc
, mbstate_t *ps
));
383 _GL_CXXALIASWARN (wcrtomb
);
385 #elif defined GNULIB_POSIXCHECK
387 # if HAVE_RAW_DECL_WCRTOMB
388 _GL_WARN_ON_USE (wcrtomb
, "wcrtomb is unportable - "
389 "use gnulib module wcrtomb for portability");
394 /* Convert a wide string to a string. */
395 #if @GNULIB_WCSRTOMBS@
396 # if @REPLACE_WCSRTOMBS@
397 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
399 # define wcsrtombs rpl_wcsrtombs
401 _GL_FUNCDECL_RPL (wcsrtombs
, size_t,
402 (char *dest
, const wchar_t **srcp
, size_t len
, mbstate_t *ps
)
403 _GL_ARG_NONNULL ((2)));
404 _GL_CXXALIAS_RPL (wcsrtombs
, size_t,
405 (char *dest
, const wchar_t **srcp
, size_t len
,
408 # if !@HAVE_WCSRTOMBS@
409 _GL_FUNCDECL_SYS (wcsrtombs
, size_t,
410 (char *dest
, const wchar_t **srcp
, size_t len
, mbstate_t *ps
)
411 _GL_ARG_NONNULL ((2)));
413 _GL_CXXALIAS_SYS (wcsrtombs
, size_t,
414 (char *dest
, const wchar_t **srcp
, size_t len
,
418 _GL_CXXALIASWARN (wcsrtombs
);
420 #elif defined GNULIB_POSIXCHECK
422 # if HAVE_RAW_DECL_WCSRTOMBS
423 _GL_WARN_ON_USE (wcsrtombs
, "wcsrtombs is unportable - "
424 "use gnulib module wcsrtombs for portability");
429 /* Convert a wide string to a string. */
430 #if @GNULIB_WCSNRTOMBS@
431 # if @REPLACE_WCSNRTOMBS@
432 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
434 # define wcsnrtombs rpl_wcsnrtombs
436 _GL_FUNCDECL_RPL (wcsnrtombs
, size_t,
437 (char *dest
, const wchar_t **srcp
, size_t srclen
, size_t len
,
439 _GL_ARG_NONNULL ((2)));
440 _GL_CXXALIAS_RPL (wcsnrtombs
, size_t,
441 (char *dest
, const wchar_t **srcp
, size_t srclen
, size_t len
,
444 # if !@HAVE_WCSNRTOMBS@ || (defined __cplusplus && defined __sun)
445 _GL_FUNCDECL_SYS (wcsnrtombs
, size_t,
446 (char *dest
, const wchar_t **srcp
, size_t srclen
, size_t len
,
448 _GL_ARG_NONNULL ((2)));
450 _GL_CXXALIAS_SYS (wcsnrtombs
, size_t,
451 (char *dest
, const wchar_t **srcp
, size_t srclen
, size_t len
,
455 _GL_CXXALIASWARN (wcsnrtombs
);
457 #elif defined GNULIB_POSIXCHECK
459 # if HAVE_RAW_DECL_WCSNRTOMBS
460 _GL_WARN_ON_USE (wcsnrtombs
, "wcsnrtombs is unportable - "
461 "use gnulib module wcsnrtombs for portability");
466 /* Return the number of screen columns needed for WC. */
468 # if @REPLACE_WCWIDTH@
469 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
471 # define wcwidth rpl_wcwidth
473 _GL_FUNCDECL_RPL (wcwidth
, int, (wchar_t) _GL_ATTRIBUTE_PURE
);
474 _GL_CXXALIAS_RPL (wcwidth
, int, (wchar_t));
476 # if !@HAVE_DECL_WCWIDTH@
477 /* wcwidth exists but is not declared. */
478 _GL_FUNCDECL_SYS (wcwidth
, int, (wchar_t) _GL_ATTRIBUTE_PURE
);
480 _GL_CXXALIAS_SYS (wcwidth
, int, (wchar_t));
483 _GL_CXXALIASWARN (wcwidth
);
485 #elif defined GNULIB_POSIXCHECK
487 # if HAVE_RAW_DECL_WCWIDTH
488 _GL_WARN_ON_USE (wcwidth
, "wcwidth is unportable - "
489 "use gnulib module wcwidth for portability");
494 /* Search N wide characters of S for C. */
497 _GL_FUNCDECL_SYS (wmemchr
, wchar_t *, (const wchar_t *s
, wchar_t c
, size_t n
)
500 /* On some systems, this function is defined as an overloaded function:
502 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
503 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
505 _GL_CXXALIAS_SYS_CAST2 (wmemchr
,
506 wchar_t *, (const wchar_t *, wchar_t, size_t),
507 const wchar_t *, (const wchar_t *, wchar_t, size_t));
508 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
509 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
510 _GL_CXXALIASWARN1 (wmemchr
, wchar_t *, (wchar_t *s
, wchar_t c
, size_t n
));
511 _GL_CXXALIASWARN1 (wmemchr
, const wchar_t *,
512 (const wchar_t *s
, wchar_t c
, size_t n
));
513 # elif __GLIBC__ >= 2
514 _GL_CXXALIASWARN (wmemchr
);
516 #elif defined GNULIB_POSIXCHECK
518 # if HAVE_RAW_DECL_WMEMCHR
519 _GL_WARN_ON_USE (wmemchr
, "wmemchr is unportable - "
520 "use gnulib module wmemchr for portability");
525 /* Compare N wide characters of S1 and S2. */
528 _GL_FUNCDECL_SYS (wmemcmp
, int,
529 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
532 _GL_CXXALIAS_SYS (wmemcmp
, int,
533 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
535 _GL_CXXALIASWARN (wmemcmp
);
537 #elif defined GNULIB_POSIXCHECK
539 # if HAVE_RAW_DECL_WMEMCMP
540 _GL_WARN_ON_USE (wmemcmp
, "wmemcmp is unportable - "
541 "use gnulib module wmemcmp for portability");
546 /* Copy N wide characters of SRC to DEST. */
549 _GL_FUNCDECL_SYS (wmemcpy
, wchar_t *,
550 (wchar_t *dest
, const wchar_t *src
, size_t n
));
552 _GL_CXXALIAS_SYS (wmemcpy
, wchar_t *,
553 (wchar_t *dest
, const wchar_t *src
, size_t n
));
555 _GL_CXXALIASWARN (wmemcpy
);
557 #elif defined GNULIB_POSIXCHECK
559 # if HAVE_RAW_DECL_WMEMCPY
560 _GL_WARN_ON_USE (wmemcpy
, "wmemcpy is unportable - "
561 "use gnulib module wmemcpy for portability");
566 /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
567 overlapping memory areas. */
568 #if @GNULIB_WMEMMOVE@
569 # if !@HAVE_WMEMMOVE@
570 _GL_FUNCDECL_SYS (wmemmove
, wchar_t *,
571 (wchar_t *dest
, const wchar_t *src
, size_t n
));
573 _GL_CXXALIAS_SYS (wmemmove
, wchar_t *,
574 (wchar_t *dest
, const wchar_t *src
, size_t n
));
576 _GL_CXXALIASWARN (wmemmove
);
578 #elif defined GNULIB_POSIXCHECK
580 # if HAVE_RAW_DECL_WMEMMOVE
581 _GL_WARN_ON_USE (wmemmove
, "wmemmove is unportable - "
582 "use gnulib module wmemmove for portability");
587 /* Set N wide characters of S to C. */
590 _GL_FUNCDECL_SYS (wmemset
, wchar_t *, (wchar_t *s
, wchar_t c
, size_t n
));
592 _GL_CXXALIAS_SYS (wmemset
, wchar_t *, (wchar_t *s
, wchar_t c
, size_t n
));
594 _GL_CXXALIASWARN (wmemset
);
596 #elif defined GNULIB_POSIXCHECK
598 # if HAVE_RAW_DECL_WMEMSET
599 _GL_WARN_ON_USE (wmemset
, "wmemset is unportable - "
600 "use gnulib module wmemset for portability");
605 /* Return the number of wide characters in S. */
608 _GL_FUNCDECL_SYS (wcslen
, size_t, (const wchar_t *s
) _GL_ATTRIBUTE_PURE
);
610 _GL_CXXALIAS_SYS (wcslen
, size_t, (const wchar_t *s
));
612 _GL_CXXALIASWARN (wcslen
);
614 #elif defined GNULIB_POSIXCHECK
616 # if HAVE_RAW_DECL_WCSLEN
617 _GL_WARN_ON_USE (wcslen
, "wcslen is unportable - "
618 "use gnulib module wcslen for portability");
623 /* Return the number of wide characters in S, but at most MAXLEN. */
626 _GL_FUNCDECL_SYS (wcsnlen
, size_t, (const wchar_t *s
, size_t maxlen
)
629 _GL_CXXALIAS_SYS (wcsnlen
, size_t, (const wchar_t *s
, size_t maxlen
));
630 _GL_CXXALIASWARN (wcsnlen
);
631 #elif defined GNULIB_POSIXCHECK
633 # if HAVE_RAW_DECL_WCSNLEN
634 _GL_WARN_ON_USE (wcsnlen
, "wcsnlen is unportable - "
635 "use gnulib module wcsnlen for portability");
640 /* Copy SRC to DEST. */
643 _GL_FUNCDECL_SYS (wcscpy
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
645 _GL_CXXALIAS_SYS (wcscpy
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
647 _GL_CXXALIASWARN (wcscpy
);
649 #elif defined GNULIB_POSIXCHECK
651 # if HAVE_RAW_DECL_WCSCPY
652 _GL_WARN_ON_USE (wcscpy
, "wcscpy is unportable - "
653 "use gnulib module wcscpy for portability");
658 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
661 _GL_FUNCDECL_SYS (wcpcpy
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
663 _GL_CXXALIAS_SYS (wcpcpy
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
664 _GL_CXXALIASWARN (wcpcpy
);
665 #elif defined GNULIB_POSIXCHECK
667 # if HAVE_RAW_DECL_WCPCPY
668 _GL_WARN_ON_USE (wcpcpy
, "wcpcpy is unportable - "
669 "use gnulib module wcpcpy for portability");
674 /* Copy no more than N wide characters of SRC to DEST. */
677 _GL_FUNCDECL_SYS (wcsncpy
, wchar_t *,
678 (wchar_t *dest
, const wchar_t *src
, size_t n
));
680 _GL_CXXALIAS_SYS (wcsncpy
, wchar_t *,
681 (wchar_t *dest
, const wchar_t *src
, size_t n
));
683 _GL_CXXALIASWARN (wcsncpy
);
685 #elif defined GNULIB_POSIXCHECK
687 # if HAVE_RAW_DECL_WCSNCPY
688 _GL_WARN_ON_USE (wcsncpy
, "wcsncpy is unportable - "
689 "use gnulib module wcsncpy for portability");
694 /* Copy no more than N characters of SRC to DEST, returning the address of
695 the last character written into DEST. */
698 _GL_FUNCDECL_SYS (wcpncpy
, wchar_t *,
699 (wchar_t *dest
, const wchar_t *src
, size_t n
));
701 _GL_CXXALIAS_SYS (wcpncpy
, wchar_t *,
702 (wchar_t *dest
, const wchar_t *src
, size_t n
));
703 _GL_CXXALIASWARN (wcpncpy
);
704 #elif defined GNULIB_POSIXCHECK
706 # if HAVE_RAW_DECL_WCPNCPY
707 _GL_WARN_ON_USE (wcpncpy
, "wcpncpy is unportable - "
708 "use gnulib module wcpncpy for portability");
713 /* Append SRC onto DEST. */
716 _GL_FUNCDECL_SYS (wcscat
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
718 _GL_CXXALIAS_SYS (wcscat
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
720 _GL_CXXALIASWARN (wcscat
);
722 #elif defined GNULIB_POSIXCHECK
724 # if HAVE_RAW_DECL_WCSCAT
725 _GL_WARN_ON_USE (wcscat
, "wcscat is unportable - "
726 "use gnulib module wcscat for portability");
731 /* Append no more than N wide characters of SRC onto DEST. */
734 _GL_FUNCDECL_SYS (wcsncat
, wchar_t *,
735 (wchar_t *dest
, const wchar_t *src
, size_t n
));
737 _GL_CXXALIAS_SYS (wcsncat
, wchar_t *,
738 (wchar_t *dest
, const wchar_t *src
, size_t n
));
740 _GL_CXXALIASWARN (wcsncat
);
742 #elif defined GNULIB_POSIXCHECK
744 # if HAVE_RAW_DECL_WCSNCAT
745 _GL_WARN_ON_USE (wcsncat
, "wcsncat is unportable - "
746 "use gnulib module wcsncat for portability");
751 /* Compare S1 and S2. */
754 _GL_FUNCDECL_SYS (wcscmp
, int, (const wchar_t *s1
, const wchar_t *s2
)
757 _GL_CXXALIAS_SYS (wcscmp
, int, (const wchar_t *s1
, const wchar_t *s2
));
759 _GL_CXXALIASWARN (wcscmp
);
761 #elif defined GNULIB_POSIXCHECK
763 # if HAVE_RAW_DECL_WCSCMP
764 _GL_WARN_ON_USE (wcscmp
, "wcscmp is unportable - "
765 "use gnulib module wcscmp for portability");
770 /* Compare no more than N wide characters of S1 and S2. */
773 _GL_FUNCDECL_SYS (wcsncmp
, int,
774 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
777 _GL_CXXALIAS_SYS (wcsncmp
, int,
778 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
780 _GL_CXXALIASWARN (wcsncmp
);
782 #elif defined GNULIB_POSIXCHECK
784 # if HAVE_RAW_DECL_WCSNCMP
785 _GL_WARN_ON_USE (wcsncmp
, "wcsncmp is unportable - "
786 "use gnulib module wcsncmp for portability");
791 /* Compare S1 and S2, ignoring case. */
792 #if @GNULIB_WCSCASECMP@
793 # if !@HAVE_WCSCASECMP@
794 _GL_FUNCDECL_SYS (wcscasecmp
, int, (const wchar_t *s1
, const wchar_t *s2
)
797 _GL_CXXALIAS_SYS (wcscasecmp
, int, (const wchar_t *s1
, const wchar_t *s2
));
798 _GL_CXXALIASWARN (wcscasecmp
);
799 #elif defined GNULIB_POSIXCHECK
801 # if HAVE_RAW_DECL_WCSCASECMP
802 _GL_WARN_ON_USE (wcscasecmp
, "wcscasecmp is unportable - "
803 "use gnulib module wcscasecmp for portability");
808 /* Compare no more than N chars of S1 and S2, ignoring case. */
809 #if @GNULIB_WCSNCASECMP@
810 # if !@HAVE_WCSNCASECMP@
811 _GL_FUNCDECL_SYS (wcsncasecmp
, int,
812 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
815 _GL_CXXALIAS_SYS (wcsncasecmp
, int,
816 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
817 _GL_CXXALIASWARN (wcsncasecmp
);
818 #elif defined GNULIB_POSIXCHECK
820 # if HAVE_RAW_DECL_WCSNCASECMP
821 _GL_WARN_ON_USE (wcsncasecmp
, "wcsncasecmp is unportable - "
822 "use gnulib module wcsncasecmp for portability");
827 /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
828 category of the current locale. */
831 _GL_FUNCDECL_SYS (wcscoll
, int, (const wchar_t *s1
, const wchar_t *s2
));
833 _GL_CXXALIAS_SYS (wcscoll
, int, (const wchar_t *s1
, const wchar_t *s2
));
835 _GL_CXXALIASWARN (wcscoll
);
837 #elif defined GNULIB_POSIXCHECK
839 # if HAVE_RAW_DECL_WCSCOLL
840 _GL_WARN_ON_USE (wcscoll
, "wcscoll is unportable - "
841 "use gnulib module wcscoll for portability");
846 /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
847 to two transformed strings the result is the as applying 'wcscoll' to the
851 _GL_FUNCDECL_SYS (wcsxfrm
, size_t, (wchar_t *s1
, const wchar_t *s2
, size_t n
));
853 _GL_CXXALIAS_SYS (wcsxfrm
, size_t, (wchar_t *s1
, const wchar_t *s2
, size_t n
));
855 _GL_CXXALIASWARN (wcsxfrm
);
857 #elif defined GNULIB_POSIXCHECK
859 # if HAVE_RAW_DECL_WCSXFRM
860 _GL_WARN_ON_USE (wcsxfrm
, "wcsxfrm is unportable - "
861 "use gnulib module wcsxfrm for portability");
866 /* Duplicate S, returning an identical malloc'd string. */
869 _GL_FUNCDECL_SYS (wcsdup
, wchar_t *, (const wchar_t *s
));
871 _GL_CXXALIAS_SYS (wcsdup
, wchar_t *, (const wchar_t *s
));
872 _GL_CXXALIASWARN (wcsdup
);
873 #elif defined GNULIB_POSIXCHECK
875 # if HAVE_RAW_DECL_WCSDUP
876 _GL_WARN_ON_USE (wcsdup
, "wcsdup is unportable - "
877 "use gnulib module wcsdup for portability");
882 /* Find the first occurrence of WC in WCS. */
885 _GL_FUNCDECL_SYS (wcschr
, wchar_t *, (const wchar_t *wcs
, wchar_t wc
)
888 /* On some systems, this function is defined as an overloaded function:
890 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
891 wchar_t * std::wcschr (wchar_t *, wchar_t);
893 _GL_CXXALIAS_SYS_CAST2 (wcschr
,
894 wchar_t *, (const wchar_t *, wchar_t),
895 const wchar_t *, (const wchar_t *, wchar_t));
896 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
897 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
898 _GL_CXXALIASWARN1 (wcschr
, wchar_t *, (wchar_t *wcs
, wchar_t wc
));
899 _GL_CXXALIASWARN1 (wcschr
, const wchar_t *, (const wchar_t *wcs
, wchar_t wc
));
900 # elif __GLIBC__ >= 2
901 _GL_CXXALIASWARN (wcschr
);
903 #elif defined GNULIB_POSIXCHECK
905 # if HAVE_RAW_DECL_WCSCHR
906 _GL_WARN_ON_USE (wcschr
, "wcschr is unportable - "
907 "use gnulib module wcschr for portability");
912 /* Find the last occurrence of WC in WCS. */
915 _GL_FUNCDECL_SYS (wcsrchr
, wchar_t *, (const wchar_t *wcs
, wchar_t wc
)
918 /* On some systems, this function is defined as an overloaded function:
920 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
921 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
923 _GL_CXXALIAS_SYS_CAST2 (wcsrchr
,
924 wchar_t *, (const wchar_t *, wchar_t),
925 const wchar_t *, (const wchar_t *, wchar_t));
926 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
927 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
928 _GL_CXXALIASWARN1 (wcsrchr
, wchar_t *, (wchar_t *wcs
, wchar_t wc
));
929 _GL_CXXALIASWARN1 (wcsrchr
, const wchar_t *, (const wchar_t *wcs
, wchar_t wc
));
930 # elif __GLIBC__ >= 2
931 _GL_CXXALIASWARN (wcsrchr
);
933 #elif defined GNULIB_POSIXCHECK
935 # if HAVE_RAW_DECL_WCSRCHR
936 _GL_WARN_ON_USE (wcsrchr
, "wcsrchr is unportable - "
937 "use gnulib module wcsrchr for portability");
942 /* Return the length of the initial segmet of WCS which consists entirely
943 of wide characters not in REJECT. */
946 _GL_FUNCDECL_SYS (wcscspn
, size_t, (const wchar_t *wcs
, const wchar_t *reject
)
949 _GL_CXXALIAS_SYS (wcscspn
, size_t, (const wchar_t *wcs
, const wchar_t *reject
));
951 _GL_CXXALIASWARN (wcscspn
);
953 #elif defined GNULIB_POSIXCHECK
955 # if HAVE_RAW_DECL_WCSCSPN
956 _GL_WARN_ON_USE (wcscspn
, "wcscspn is unportable - "
957 "use gnulib module wcscspn for portability");
962 /* Return the length of the initial segmet of WCS which consists entirely
963 of wide characters in ACCEPT. */
966 _GL_FUNCDECL_SYS (wcsspn
, size_t, (const wchar_t *wcs
, const wchar_t *accept
)
969 _GL_CXXALIAS_SYS (wcsspn
, size_t, (const wchar_t *wcs
, const wchar_t *accept
));
971 _GL_CXXALIASWARN (wcsspn
);
973 #elif defined GNULIB_POSIXCHECK
975 # if HAVE_RAW_DECL_WCSSPN
976 _GL_WARN_ON_USE (wcsspn
, "wcsspn is unportable - "
977 "use gnulib module wcsspn for portability");
982 /* Find the first occurrence in WCS of any character in ACCEPT. */
985 _GL_FUNCDECL_SYS (wcspbrk
, wchar_t *,
986 (const wchar_t *wcs
, const wchar_t *accept
)
989 /* On some systems, this function is defined as an overloaded function:
991 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
992 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
994 _GL_CXXALIAS_SYS_CAST2 (wcspbrk
,
995 wchar_t *, (const wchar_t *, const wchar_t *),
996 const wchar_t *, (const wchar_t *, const wchar_t *));
997 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
998 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
999 _GL_CXXALIASWARN1 (wcspbrk
, wchar_t *,
1000 (wchar_t *wcs
, const wchar_t *accept
));
1001 _GL_CXXALIASWARN1 (wcspbrk
, const wchar_t *,
1002 (const wchar_t *wcs
, const wchar_t *accept
));
1003 # elif __GLIBC__ >= 2
1004 _GL_CXXALIASWARN (wcspbrk
);
1006 #elif defined GNULIB_POSIXCHECK
1008 # if HAVE_RAW_DECL_WCSPBRK
1009 _GL_WARN_ON_USE (wcspbrk
, "wcspbrk is unportable - "
1010 "use gnulib module wcspbrk for portability");
1015 /* Find the first occurrence of NEEDLE in HAYSTACK. */
1018 _GL_FUNCDECL_SYS (wcsstr
, wchar_t *,
1019 (const wchar_t *haystack
, const wchar_t *needle
)
1020 _GL_ATTRIBUTE_PURE
);
1022 /* On some systems, this function is defined as an overloaded function:
1024 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
1025 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
1027 _GL_CXXALIAS_SYS_CAST2 (wcsstr
,
1028 wchar_t *, (const wchar_t *, const wchar_t *),
1029 const wchar_t *, (const wchar_t *, const wchar_t *));
1030 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1031 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1032 _GL_CXXALIASWARN1 (wcsstr
, wchar_t *,
1033 (wchar_t *haystack
, const wchar_t *needle
));
1034 _GL_CXXALIASWARN1 (wcsstr
, const wchar_t *,
1035 (const wchar_t *haystack
, const wchar_t *needle
));
1036 # elif __GLIBC__ >= 2
1037 _GL_CXXALIASWARN (wcsstr
);
1039 #elif defined GNULIB_POSIXCHECK
1041 # if HAVE_RAW_DECL_WCSSTR
1042 _GL_WARN_ON_USE (wcsstr
, "wcsstr is unportable - "
1043 "use gnulib module wcsstr for portability");
1048 /* Divide WCS into tokens separated by characters in DELIM. */
1050 # if @REPLACE_WCSTOK@
1051 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1053 # define wcstok rpl_wcstok
1055 _GL_FUNCDECL_RPL (wcstok
, wchar_t *,
1056 (wchar_t *wcs
, const wchar_t *delim
, wchar_t **ptr
));
1057 _GL_CXXALIAS_RPL (wcstok
, wchar_t *,
1058 (wchar_t *wcs
, const wchar_t *delim
, wchar_t **ptr
));
1061 _GL_FUNCDECL_SYS (wcstok
, wchar_t *,
1062 (wchar_t *wcs
, const wchar_t *delim
, wchar_t **ptr
));
1064 _GL_CXXALIAS_SYS (wcstok
, wchar_t *,
1065 (wchar_t *wcs
, const wchar_t *delim
, wchar_t **ptr
));
1068 _GL_CXXALIASWARN (wcstok
);
1070 #elif defined GNULIB_POSIXCHECK
1072 # if HAVE_RAW_DECL_WCSTOK
1073 _GL_WARN_ON_USE (wcstok
, "wcstok is unportable - "
1074 "use gnulib module wcstok for portability");
1079 /* Determine number of column positions required for first N wide
1080 characters (or fewer if S ends before this) in S. */
1081 #if @GNULIB_WCSWIDTH@
1082 # if @REPLACE_WCSWIDTH@
1083 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1085 # define wcswidth rpl_wcswidth
1087 _GL_FUNCDECL_RPL (wcswidth
, int, (const wchar_t *s
, size_t n
)
1088 _GL_ATTRIBUTE_PURE
);
1089 _GL_CXXALIAS_RPL (wcswidth
, int, (const wchar_t *s
, size_t n
));
1091 # if !@HAVE_WCSWIDTH@
1092 _GL_FUNCDECL_SYS (wcswidth
, int, (const wchar_t *s
, size_t n
)
1093 _GL_ATTRIBUTE_PURE
);
1095 _GL_CXXALIAS_SYS (wcswidth
, int, (const wchar_t *s
, size_t n
));
1098 _GL_CXXALIASWARN (wcswidth
);
1100 #elif defined GNULIB_POSIXCHECK
1102 # if HAVE_RAW_DECL_WCSWIDTH
1103 _GL_WARN_ON_USE (wcswidth
, "wcswidth is unportable - "
1104 "use gnulib module wcswidth for portability");
1109 /* Convert *TP to a date and time wide string. See
1110 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
1111 #if @GNULIB_WCSFTIME@
1112 # if @REPLACE_WCSFTIME@
1113 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1115 # define wcsftime rpl_wcsftime
1117 _GL_FUNCDECL_RPL (wcsftime
, size_t, (wchar_t *__buf
, size_t __bufsize
,
1118 const wchar_t *__fmt
, const struct tm
*__tp
)
1119 _GL_ARG_NONNULL ((1, 3, 4)));
1120 _GL_CXXALIAS_RPL (wcsftime
, size_t, (wchar_t *__buf
, size_t __bufsize
,
1121 const wchar_t *__fmt
, const struct tm
*__tp
));
1123 # if !@HAVE_WCSFTIME@
1124 _GL_FUNCDECL_SYS (wcsftime
, size_t, (wchar_t *__buf
, size_t __bufsize
,
1125 const wchar_t *__fmt
, const struct tm
*__tp
)
1126 _GL_ARG_NONNULL ((1, 3, 4)));
1128 _GL_CXXALIAS_SYS (wcsftime
, size_t, (wchar_t *__buf
, size_t __bufsize
,
1129 const wchar_t *__fmt
, const struct tm
*__tp
));
1132 _GL_CXXALIASWARN (wcsftime
);
1134 #elif defined GNULIB_POSIXCHECK
1136 # if HAVE_RAW_DECL_WCSFTIME
1137 _GL_WARN_ON_USE (wcsftime
, "wcsftime is unportable - "
1138 "use gnulib module wcsftime for portability");
1143 #endif /* _@GUARD_PREFIX@_WCHAR_H */
1144 #endif /* _@GUARD_PREFIX@_WCHAR_H */