1 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
3 Copyright (C) 2007-2019 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 3, 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 && !defined strtoimax) \
37 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
38 || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
39 || defined _GL_ALREADY_INCLUDING_WCHAR_H)
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 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
51 the latter includes <wchar.h>. But here, we have no way to detect whether
52 <wctype.h> is completely included or is still being included. */
54 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
57 /* Normal invocation convention. */
59 #ifndef _@GUARD_PREFIX@_WCHAR_H
61 #define _GL_ALREADY_INCLUDING_WCHAR_H
64 # include <features.h> /* for __GLIBC__ */
67 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
69 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
70 included before <wchar.h>.
71 In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
73 But avoid namespace pollution on glibc systems. */
74 #if !(defined __GLIBC__ && !defined __UCLIBC__)
82 /* Include the original <wchar.h> if it exists.
83 Some builds of uClibc lack it. */
84 /* The include_next requires a split double-inclusion guard. */
86 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
89 #undef _GL_ALREADY_INCLUDING_WCHAR_H
91 #ifndef _@GUARD_PREFIX@_WCHAR_H
92 #define _@GUARD_PREFIX@_WCHAR_H
94 /* The __attribute__ feature is available in gcc versions 2.5 and later.
95 The attribute __pure__ was added in gcc 2.96. */
96 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
97 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
99 # define _GL_ATTRIBUTE_PURE /* empty */
102 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
104 /* The definition of _GL_ARG_NONNULL is copied here. */
106 /* The definition of _GL_WARN_ON_USE is copied here. */
109 /* Define wint_t and WEOF. (Also done in wctype.in.h.) */
110 #if !@HAVE_WINT_T@ && !defined wint_t
116 /* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
117 <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
118 wint_t must be "unchanged by default argument promotions". Override it. */
119 # if @GNULIB_OVERRIDES_WINT_T@
120 # if !GNULIB_defined_wint_t
121 # if @HAVE_CRTDEFS_H@
122 # include <crtdefs.h>
126 typedef unsigned int rpl_wint_t
;
128 # define wint_t rpl_wint_t
129 # define GNULIB_defined_wint_t 1
133 # define WEOF ((wint_t) -1)
138 /* Override mbstate_t if it is too small.
139 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
140 implementing mbrtowc for encodings like UTF-8.
141 On AIX and MSVC, mbrtowc needs to be overridden, but mbstate_t exists and is
142 large enough and overriding it would cause problems in C++ mode. */
143 #if (!(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@) \
144 && !(defined _AIX || defined _MSC_VER)
145 # if !GNULIB_defined_mbstate_t
146 typedef int rpl_mbstate_t
;
148 # define mbstate_t rpl_mbstate_t
149 # define GNULIB_defined_mbstate_t 1
154 /* Convert a single-byte character to a wide character. */
157 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
159 # define btowc rpl_btowc
161 _GL_FUNCDECL_RPL (btowc
, wint_t, (int c
) _GL_ATTRIBUTE_PURE
);
162 _GL_CXXALIAS_RPL (btowc
, wint_t, (int c
));
165 _GL_FUNCDECL_SYS (btowc
, wint_t, (int c
) _GL_ATTRIBUTE_PURE
);
167 /* Need to cast, because on mingw, the return type is 'unsigned short'. */
168 _GL_CXXALIAS_SYS_CAST (btowc
, wint_t, (int c
));
171 _GL_CXXALIASWARN (btowc
);
173 #elif defined GNULIB_POSIXCHECK
175 # if HAVE_RAW_DECL_BTOWC
176 _GL_WARN_ON_USE (btowc
, "btowc is unportable - "
177 "use gnulib module btowc for portability");
182 /* Convert a wide character to a single-byte character. */
185 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
187 # define wctob rpl_wctob
189 _GL_FUNCDECL_RPL (wctob
, int, (wint_t wc
) _GL_ATTRIBUTE_PURE
);
190 _GL_CXXALIAS_RPL (wctob
, int, (wint_t wc
));
192 # if !defined wctob && !@HAVE_DECL_WCTOB@
193 /* wctob is provided by gnulib, or wctob exists but is not declared. */
194 _GL_FUNCDECL_SYS (wctob
, int, (wint_t wc
) _GL_ATTRIBUTE_PURE
);
196 _GL_CXXALIAS_SYS (wctob
, int, (wint_t wc
));
199 _GL_CXXALIASWARN (wctob
);
201 #elif defined GNULIB_POSIXCHECK
203 # if HAVE_RAW_DECL_WCTOB
204 _GL_WARN_ON_USE (wctob
, "wctob is unportable - "
205 "use gnulib module wctob for portability");
210 /* Test whether *PS is in the initial state. */
212 # if @REPLACE_MBSINIT@
213 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
215 # define mbsinit rpl_mbsinit
217 _GL_FUNCDECL_RPL (mbsinit
, int, (const mbstate_t *ps
));
218 _GL_CXXALIAS_RPL (mbsinit
, int, (const mbstate_t *ps
));
221 _GL_FUNCDECL_SYS (mbsinit
, int, (const mbstate_t *ps
));
223 _GL_CXXALIAS_SYS (mbsinit
, int, (const mbstate_t *ps
));
226 _GL_CXXALIASWARN (mbsinit
);
228 #elif defined GNULIB_POSIXCHECK
230 # if HAVE_RAW_DECL_MBSINIT
231 _GL_WARN_ON_USE (mbsinit
, "mbsinit is unportable - "
232 "use gnulib module mbsinit for portability");
237 /* Convert a multibyte character to a wide character. */
239 # if @REPLACE_MBRTOWC@
240 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
242 # define mbrtowc rpl_mbrtowc
244 _GL_FUNCDECL_RPL (mbrtowc
, size_t,
245 (wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
));
246 _GL_CXXALIAS_RPL (mbrtowc
, size_t,
247 (wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
));
250 _GL_FUNCDECL_SYS (mbrtowc
, size_t,
251 (wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
));
253 _GL_CXXALIAS_SYS (mbrtowc
, size_t,
254 (wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
));
257 _GL_CXXALIASWARN (mbrtowc
);
259 #elif defined GNULIB_POSIXCHECK
261 # if HAVE_RAW_DECL_MBRTOWC
262 _GL_WARN_ON_USE (mbrtowc
, "mbrtowc is unportable - "
263 "use gnulib module mbrtowc for portability");
268 /* Recognize a multibyte character. */
270 # if @REPLACE_MBRLEN@
271 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
273 # define mbrlen rpl_mbrlen
275 _GL_FUNCDECL_RPL (mbrlen
, size_t, (const char *s
, size_t n
, mbstate_t *ps
));
276 _GL_CXXALIAS_RPL (mbrlen
, size_t, (const char *s
, size_t n
, mbstate_t *ps
));
279 _GL_FUNCDECL_SYS (mbrlen
, size_t, (const char *s
, size_t n
, mbstate_t *ps
));
281 _GL_CXXALIAS_SYS (mbrlen
, size_t, (const char *s
, size_t n
, mbstate_t *ps
));
284 _GL_CXXALIASWARN (mbrlen
);
286 #elif defined GNULIB_POSIXCHECK
288 # if HAVE_RAW_DECL_MBRLEN
289 _GL_WARN_ON_USE (mbrlen
, "mbrlen is unportable - "
290 "use gnulib module mbrlen for portability");
295 /* Convert a string to a wide string. */
296 #if @GNULIB_MBSRTOWCS@
297 # if @REPLACE_MBSRTOWCS@
298 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
300 # define mbsrtowcs rpl_mbsrtowcs
302 _GL_FUNCDECL_RPL (mbsrtowcs
, size_t,
303 (wchar_t *dest
, const char **srcp
, size_t len
, mbstate_t *ps
)
304 _GL_ARG_NONNULL ((2)));
305 _GL_CXXALIAS_RPL (mbsrtowcs
, size_t,
306 (wchar_t *dest
, const char **srcp
, size_t len
,
309 # if !@HAVE_MBSRTOWCS@
310 _GL_FUNCDECL_SYS (mbsrtowcs
, size_t,
311 (wchar_t *dest
, const char **srcp
, size_t len
, mbstate_t *ps
)
312 _GL_ARG_NONNULL ((2)));
314 _GL_CXXALIAS_SYS (mbsrtowcs
, size_t,
315 (wchar_t *dest
, const char **srcp
, size_t len
,
319 _GL_CXXALIASWARN (mbsrtowcs
);
321 #elif defined GNULIB_POSIXCHECK
323 # if HAVE_RAW_DECL_MBSRTOWCS
324 _GL_WARN_ON_USE (mbsrtowcs
, "mbsrtowcs is unportable - "
325 "use gnulib module mbsrtowcs for portability");
330 /* Convert a string to a wide string. */
331 #if @GNULIB_MBSNRTOWCS@
332 # if @REPLACE_MBSNRTOWCS@
333 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
335 # define mbsnrtowcs rpl_mbsnrtowcs
337 _GL_FUNCDECL_RPL (mbsnrtowcs
, size_t,
338 (wchar_t *dest
, const char **srcp
, size_t srclen
, size_t len
,
340 _GL_ARG_NONNULL ((2)));
341 _GL_CXXALIAS_RPL (mbsnrtowcs
, size_t,
342 (wchar_t *dest
, const char **srcp
, size_t srclen
, size_t len
,
345 # if !@HAVE_MBSNRTOWCS@
346 _GL_FUNCDECL_SYS (mbsnrtowcs
, size_t,
347 (wchar_t *dest
, const char **srcp
, size_t srclen
, size_t len
,
349 _GL_ARG_NONNULL ((2)));
351 _GL_CXXALIAS_SYS (mbsnrtowcs
, size_t,
352 (wchar_t *dest
, const char **srcp
, size_t srclen
, size_t len
,
355 _GL_CXXALIASWARN (mbsnrtowcs
);
356 #elif defined GNULIB_POSIXCHECK
358 # if HAVE_RAW_DECL_MBSNRTOWCS
359 _GL_WARN_ON_USE (mbsnrtowcs
, "mbsnrtowcs is unportable - "
360 "use gnulib module mbsnrtowcs for portability");
365 /* Convert a wide character to a multibyte character. */
367 # if @REPLACE_WCRTOMB@
368 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
370 # define wcrtomb rpl_wcrtomb
372 _GL_FUNCDECL_RPL (wcrtomb
, size_t, (char *s
, wchar_t wc
, mbstate_t *ps
));
373 _GL_CXXALIAS_RPL (wcrtomb
, size_t, (char *s
, wchar_t wc
, mbstate_t *ps
));
376 _GL_FUNCDECL_SYS (wcrtomb
, size_t, (char *s
, wchar_t wc
, mbstate_t *ps
));
378 _GL_CXXALIAS_SYS (wcrtomb
, size_t, (char *s
, wchar_t wc
, mbstate_t *ps
));
381 _GL_CXXALIASWARN (wcrtomb
);
383 #elif defined GNULIB_POSIXCHECK
385 # if HAVE_RAW_DECL_WCRTOMB
386 _GL_WARN_ON_USE (wcrtomb
, "wcrtomb is unportable - "
387 "use gnulib module wcrtomb for portability");
392 /* Convert a wide string to a string. */
393 #if @GNULIB_WCSRTOMBS@
394 # if @REPLACE_WCSRTOMBS@
395 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
397 # define wcsrtombs rpl_wcsrtombs
399 _GL_FUNCDECL_RPL (wcsrtombs
, size_t,
400 (char *dest
, const wchar_t **srcp
, size_t len
, mbstate_t *ps
)
401 _GL_ARG_NONNULL ((2)));
402 _GL_CXXALIAS_RPL (wcsrtombs
, size_t,
403 (char *dest
, const wchar_t **srcp
, size_t len
,
406 # if !@HAVE_WCSRTOMBS@
407 _GL_FUNCDECL_SYS (wcsrtombs
, size_t,
408 (char *dest
, const wchar_t **srcp
, size_t len
, mbstate_t *ps
)
409 _GL_ARG_NONNULL ((2)));
411 _GL_CXXALIAS_SYS (wcsrtombs
, size_t,
412 (char *dest
, const wchar_t **srcp
, size_t len
,
416 _GL_CXXALIASWARN (wcsrtombs
);
418 #elif defined GNULIB_POSIXCHECK
420 # if HAVE_RAW_DECL_WCSRTOMBS
421 _GL_WARN_ON_USE (wcsrtombs
, "wcsrtombs is unportable - "
422 "use gnulib module wcsrtombs for portability");
427 /* Convert a wide string to a string. */
428 #if @GNULIB_WCSNRTOMBS@
429 # if @REPLACE_WCSNRTOMBS@
430 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
432 # define wcsnrtombs rpl_wcsnrtombs
434 _GL_FUNCDECL_RPL (wcsnrtombs
, size_t,
435 (char *dest
, const wchar_t **srcp
, size_t srclen
, size_t len
,
437 _GL_ARG_NONNULL ((2)));
438 _GL_CXXALIAS_RPL (wcsnrtombs
, size_t,
439 (char *dest
, const wchar_t **srcp
, size_t srclen
, size_t len
,
442 # if !@HAVE_WCSNRTOMBS@ || (defined __cplusplus && defined __sun)
443 _GL_FUNCDECL_SYS (wcsnrtombs
, size_t,
444 (char *dest
, const wchar_t **srcp
, size_t srclen
, size_t len
,
446 _GL_ARG_NONNULL ((2)));
448 _GL_CXXALIAS_SYS (wcsnrtombs
, size_t,
449 (char *dest
, const wchar_t **srcp
, size_t srclen
, size_t len
,
453 _GL_CXXALIASWARN (wcsnrtombs
);
455 #elif defined GNULIB_POSIXCHECK
457 # if HAVE_RAW_DECL_WCSNRTOMBS
458 _GL_WARN_ON_USE (wcsnrtombs
, "wcsnrtombs is unportable - "
459 "use gnulib module wcsnrtombs for portability");
464 /* Return the number of screen columns needed for WC. */
466 # if @REPLACE_WCWIDTH@
467 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
469 # define wcwidth rpl_wcwidth
471 _GL_FUNCDECL_RPL (wcwidth
, int, (wchar_t) _GL_ATTRIBUTE_PURE
);
472 _GL_CXXALIAS_RPL (wcwidth
, int, (wchar_t));
474 # if !@HAVE_DECL_WCWIDTH@
475 /* wcwidth exists but is not declared. */
476 _GL_FUNCDECL_SYS (wcwidth
, int, (wchar_t) _GL_ATTRIBUTE_PURE
);
478 _GL_CXXALIAS_SYS (wcwidth
, int, (wchar_t));
481 _GL_CXXALIASWARN (wcwidth
);
483 #elif defined GNULIB_POSIXCHECK
485 # if HAVE_RAW_DECL_WCWIDTH
486 _GL_WARN_ON_USE (wcwidth
, "wcwidth is unportable - "
487 "use gnulib module wcwidth for portability");
492 /* Search N wide characters of S for C. */
495 _GL_FUNCDECL_SYS (wmemchr
, wchar_t *, (const wchar_t *s
, wchar_t c
, size_t n
)
498 /* On some systems, this function is defined as an overloaded function:
500 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
501 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
503 _GL_CXXALIAS_SYS_CAST2 (wmemchr
,
504 wchar_t *, (const wchar_t *, wchar_t, size_t),
505 const wchar_t *, (const wchar_t *, wchar_t, size_t));
506 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
507 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
508 _GL_CXXALIASWARN1 (wmemchr
, wchar_t *, (wchar_t *s
, wchar_t c
, size_t n
));
509 _GL_CXXALIASWARN1 (wmemchr
, const wchar_t *,
510 (const wchar_t *s
, wchar_t c
, size_t n
));
511 # elif __GLIBC__ >= 2
512 _GL_CXXALIASWARN (wmemchr
);
514 #elif defined GNULIB_POSIXCHECK
516 # if HAVE_RAW_DECL_WMEMCHR
517 _GL_WARN_ON_USE (wmemchr
, "wmemchr is unportable - "
518 "use gnulib module wmemchr for portability");
523 /* Compare N wide characters of S1 and S2. */
526 _GL_FUNCDECL_SYS (wmemcmp
, int,
527 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
530 _GL_CXXALIAS_SYS (wmemcmp
, int,
531 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
533 _GL_CXXALIASWARN (wmemcmp
);
535 #elif defined GNULIB_POSIXCHECK
537 # if HAVE_RAW_DECL_WMEMCMP
538 _GL_WARN_ON_USE (wmemcmp
, "wmemcmp is unportable - "
539 "use gnulib module wmemcmp for portability");
544 /* Copy N wide characters of SRC to DEST. */
547 _GL_FUNCDECL_SYS (wmemcpy
, wchar_t *,
548 (wchar_t *dest
, const wchar_t *src
, size_t n
));
550 _GL_CXXALIAS_SYS (wmemcpy
, wchar_t *,
551 (wchar_t *dest
, const wchar_t *src
, size_t n
));
553 _GL_CXXALIASWARN (wmemcpy
);
555 #elif defined GNULIB_POSIXCHECK
557 # if HAVE_RAW_DECL_WMEMCPY
558 _GL_WARN_ON_USE (wmemcpy
, "wmemcpy is unportable - "
559 "use gnulib module wmemcpy for portability");
564 /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
565 overlapping memory areas. */
566 #if @GNULIB_WMEMMOVE@
567 # if !@HAVE_WMEMMOVE@
568 _GL_FUNCDECL_SYS (wmemmove
, wchar_t *,
569 (wchar_t *dest
, const wchar_t *src
, size_t n
));
571 _GL_CXXALIAS_SYS (wmemmove
, wchar_t *,
572 (wchar_t *dest
, const wchar_t *src
, size_t n
));
574 _GL_CXXALIASWARN (wmemmove
);
576 #elif defined GNULIB_POSIXCHECK
578 # if HAVE_RAW_DECL_WMEMMOVE
579 _GL_WARN_ON_USE (wmemmove
, "wmemmove is unportable - "
580 "use gnulib module wmemmove for portability");
585 /* Set N wide characters of S to C. */
588 _GL_FUNCDECL_SYS (wmemset
, wchar_t *, (wchar_t *s
, wchar_t c
, size_t n
));
590 _GL_CXXALIAS_SYS (wmemset
, wchar_t *, (wchar_t *s
, wchar_t c
, size_t n
));
592 _GL_CXXALIASWARN (wmemset
);
594 #elif defined GNULIB_POSIXCHECK
596 # if HAVE_RAW_DECL_WMEMSET
597 _GL_WARN_ON_USE (wmemset
, "wmemset is unportable - "
598 "use gnulib module wmemset for portability");
603 /* Return the number of wide characters in S. */
606 _GL_FUNCDECL_SYS (wcslen
, size_t, (const wchar_t *s
) _GL_ATTRIBUTE_PURE
);
608 _GL_CXXALIAS_SYS (wcslen
, size_t, (const wchar_t *s
));
610 _GL_CXXALIASWARN (wcslen
);
612 #elif defined GNULIB_POSIXCHECK
614 # if HAVE_RAW_DECL_WCSLEN
615 _GL_WARN_ON_USE (wcslen
, "wcslen is unportable - "
616 "use gnulib module wcslen for portability");
621 /* Return the number of wide characters in S, but at most MAXLEN. */
624 _GL_FUNCDECL_SYS (wcsnlen
, size_t, (const wchar_t *s
, size_t maxlen
)
627 _GL_CXXALIAS_SYS (wcsnlen
, size_t, (const wchar_t *s
, size_t maxlen
));
628 _GL_CXXALIASWARN (wcsnlen
);
629 #elif defined GNULIB_POSIXCHECK
631 # if HAVE_RAW_DECL_WCSNLEN
632 _GL_WARN_ON_USE (wcsnlen
, "wcsnlen is unportable - "
633 "use gnulib module wcsnlen for portability");
638 /* Copy SRC to DEST. */
641 _GL_FUNCDECL_SYS (wcscpy
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
643 _GL_CXXALIAS_SYS (wcscpy
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
645 _GL_CXXALIASWARN (wcscpy
);
647 #elif defined GNULIB_POSIXCHECK
649 # if HAVE_RAW_DECL_WCSCPY
650 _GL_WARN_ON_USE (wcscpy
, "wcscpy is unportable - "
651 "use gnulib module wcscpy for portability");
656 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
659 _GL_FUNCDECL_SYS (wcpcpy
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
661 _GL_CXXALIAS_SYS (wcpcpy
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
662 _GL_CXXALIASWARN (wcpcpy
);
663 #elif defined GNULIB_POSIXCHECK
665 # if HAVE_RAW_DECL_WCPCPY
666 _GL_WARN_ON_USE (wcpcpy
, "wcpcpy is unportable - "
667 "use gnulib module wcpcpy for portability");
672 /* Copy no more than N wide characters of SRC to DEST. */
675 _GL_FUNCDECL_SYS (wcsncpy
, wchar_t *,
676 (wchar_t *dest
, const wchar_t *src
, size_t n
));
678 _GL_CXXALIAS_SYS (wcsncpy
, wchar_t *,
679 (wchar_t *dest
, const wchar_t *src
, size_t n
));
681 _GL_CXXALIASWARN (wcsncpy
);
683 #elif defined GNULIB_POSIXCHECK
685 # if HAVE_RAW_DECL_WCSNCPY
686 _GL_WARN_ON_USE (wcsncpy
, "wcsncpy is unportable - "
687 "use gnulib module wcsncpy for portability");
692 /* Copy no more than N characters of SRC to DEST, returning the address of
693 the last character written into DEST. */
696 _GL_FUNCDECL_SYS (wcpncpy
, wchar_t *,
697 (wchar_t *dest
, const wchar_t *src
, size_t n
));
699 _GL_CXXALIAS_SYS (wcpncpy
, wchar_t *,
700 (wchar_t *dest
, const wchar_t *src
, size_t n
));
701 _GL_CXXALIASWARN (wcpncpy
);
702 #elif defined GNULIB_POSIXCHECK
704 # if HAVE_RAW_DECL_WCPNCPY
705 _GL_WARN_ON_USE (wcpncpy
, "wcpncpy is unportable - "
706 "use gnulib module wcpncpy for portability");
711 /* Append SRC onto DEST. */
714 _GL_FUNCDECL_SYS (wcscat
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
716 _GL_CXXALIAS_SYS (wcscat
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
718 _GL_CXXALIASWARN (wcscat
);
720 #elif defined GNULIB_POSIXCHECK
722 # if HAVE_RAW_DECL_WCSCAT
723 _GL_WARN_ON_USE (wcscat
, "wcscat is unportable - "
724 "use gnulib module wcscat for portability");
729 /* Append no more than N wide characters of SRC onto DEST. */
732 _GL_FUNCDECL_SYS (wcsncat
, wchar_t *,
733 (wchar_t *dest
, const wchar_t *src
, size_t n
));
735 _GL_CXXALIAS_SYS (wcsncat
, wchar_t *,
736 (wchar_t *dest
, const wchar_t *src
, size_t n
));
738 _GL_CXXALIASWARN (wcsncat
);
740 #elif defined GNULIB_POSIXCHECK
742 # if HAVE_RAW_DECL_WCSNCAT
743 _GL_WARN_ON_USE (wcsncat
, "wcsncat is unportable - "
744 "use gnulib module wcsncat for portability");
749 /* Compare S1 and S2. */
752 _GL_FUNCDECL_SYS (wcscmp
, int, (const wchar_t *s1
, const wchar_t *s2
)
755 _GL_CXXALIAS_SYS (wcscmp
, int, (const wchar_t *s1
, const wchar_t *s2
));
757 _GL_CXXALIASWARN (wcscmp
);
759 #elif defined GNULIB_POSIXCHECK
761 # if HAVE_RAW_DECL_WCSCMP
762 _GL_WARN_ON_USE (wcscmp
, "wcscmp is unportable - "
763 "use gnulib module wcscmp for portability");
768 /* Compare no more than N wide characters of S1 and S2. */
771 _GL_FUNCDECL_SYS (wcsncmp
, int,
772 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
775 _GL_CXXALIAS_SYS (wcsncmp
, int,
776 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
778 _GL_CXXALIASWARN (wcsncmp
);
780 #elif defined GNULIB_POSIXCHECK
782 # if HAVE_RAW_DECL_WCSNCMP
783 _GL_WARN_ON_USE (wcsncmp
, "wcsncmp is unportable - "
784 "use gnulib module wcsncmp for portability");
789 /* Compare S1 and S2, ignoring case. */
790 #if @GNULIB_WCSCASECMP@
791 # if !@HAVE_WCSCASECMP@
792 _GL_FUNCDECL_SYS (wcscasecmp
, int, (const wchar_t *s1
, const wchar_t *s2
)
795 _GL_CXXALIAS_SYS (wcscasecmp
, int, (const wchar_t *s1
, const wchar_t *s2
));
796 _GL_CXXALIASWARN (wcscasecmp
);
797 #elif defined GNULIB_POSIXCHECK
799 # if HAVE_RAW_DECL_WCSCASECMP
800 _GL_WARN_ON_USE (wcscasecmp
, "wcscasecmp is unportable - "
801 "use gnulib module wcscasecmp for portability");
806 /* Compare no more than N chars of S1 and S2, ignoring case. */
807 #if @GNULIB_WCSNCASECMP@
808 # if !@HAVE_WCSNCASECMP@
809 _GL_FUNCDECL_SYS (wcsncasecmp
, int,
810 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
813 _GL_CXXALIAS_SYS (wcsncasecmp
, int,
814 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
815 _GL_CXXALIASWARN (wcsncasecmp
);
816 #elif defined GNULIB_POSIXCHECK
818 # if HAVE_RAW_DECL_WCSNCASECMP
819 _GL_WARN_ON_USE (wcsncasecmp
, "wcsncasecmp is unportable - "
820 "use gnulib module wcsncasecmp for portability");
825 /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
826 category of the current locale. */
829 _GL_FUNCDECL_SYS (wcscoll
, int, (const wchar_t *s1
, const wchar_t *s2
));
831 _GL_CXXALIAS_SYS (wcscoll
, int, (const wchar_t *s1
, const wchar_t *s2
));
833 _GL_CXXALIASWARN (wcscoll
);
835 #elif defined GNULIB_POSIXCHECK
837 # if HAVE_RAW_DECL_WCSCOLL
838 _GL_WARN_ON_USE (wcscoll
, "wcscoll is unportable - "
839 "use gnulib module wcscoll for portability");
844 /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
845 to two transformed strings the result is the as applying 'wcscoll' to the
849 _GL_FUNCDECL_SYS (wcsxfrm
, size_t, (wchar_t *s1
, const wchar_t *s2
, size_t n
));
851 _GL_CXXALIAS_SYS (wcsxfrm
, size_t, (wchar_t *s1
, const wchar_t *s2
, size_t n
));
853 _GL_CXXALIASWARN (wcsxfrm
);
855 #elif defined GNULIB_POSIXCHECK
857 # if HAVE_RAW_DECL_WCSXFRM
858 _GL_WARN_ON_USE (wcsxfrm
, "wcsxfrm is unportable - "
859 "use gnulib module wcsxfrm for portability");
864 /* Duplicate S, returning an identical malloc'd string. */
867 _GL_FUNCDECL_SYS (wcsdup
, wchar_t *, (const wchar_t *s
));
869 _GL_CXXALIAS_SYS (wcsdup
, wchar_t *, (const wchar_t *s
));
870 _GL_CXXALIASWARN (wcsdup
);
871 #elif defined GNULIB_POSIXCHECK
873 # if HAVE_RAW_DECL_WCSDUP
874 _GL_WARN_ON_USE (wcsdup
, "wcsdup is unportable - "
875 "use gnulib module wcsdup for portability");
880 /* Find the first occurrence of WC in WCS. */
883 _GL_FUNCDECL_SYS (wcschr
, wchar_t *, (const wchar_t *wcs
, wchar_t wc
)
886 /* On some systems, this function is defined as an overloaded function:
888 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
889 wchar_t * std::wcschr (wchar_t *, wchar_t);
891 _GL_CXXALIAS_SYS_CAST2 (wcschr
,
892 wchar_t *, (const wchar_t *, wchar_t),
893 const wchar_t *, (const wchar_t *, wchar_t));
894 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
895 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
896 _GL_CXXALIASWARN1 (wcschr
, wchar_t *, (wchar_t *wcs
, wchar_t wc
));
897 _GL_CXXALIASWARN1 (wcschr
, const wchar_t *, (const wchar_t *wcs
, wchar_t wc
));
898 # elif __GLIBC__ >= 2
899 _GL_CXXALIASWARN (wcschr
);
901 #elif defined GNULIB_POSIXCHECK
903 # if HAVE_RAW_DECL_WCSCHR
904 _GL_WARN_ON_USE (wcschr
, "wcschr is unportable - "
905 "use gnulib module wcschr for portability");
910 /* Find the last occurrence of WC in WCS. */
913 _GL_FUNCDECL_SYS (wcsrchr
, wchar_t *, (const wchar_t *wcs
, wchar_t wc
)
916 /* On some systems, this function is defined as an overloaded function:
918 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
919 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
921 _GL_CXXALIAS_SYS_CAST2 (wcsrchr
,
922 wchar_t *, (const wchar_t *, wchar_t),
923 const wchar_t *, (const wchar_t *, wchar_t));
924 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
925 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
926 _GL_CXXALIASWARN1 (wcsrchr
, wchar_t *, (wchar_t *wcs
, wchar_t wc
));
927 _GL_CXXALIASWARN1 (wcsrchr
, const wchar_t *, (const wchar_t *wcs
, wchar_t wc
));
928 # elif __GLIBC__ >= 2
929 _GL_CXXALIASWARN (wcsrchr
);
931 #elif defined GNULIB_POSIXCHECK
933 # if HAVE_RAW_DECL_WCSRCHR
934 _GL_WARN_ON_USE (wcsrchr
, "wcsrchr is unportable - "
935 "use gnulib module wcsrchr for portability");
940 /* Return the length of the initial segmet of WCS which consists entirely
941 of wide characters not in REJECT. */
944 _GL_FUNCDECL_SYS (wcscspn
, size_t, (const wchar_t *wcs
, const wchar_t *reject
)
947 _GL_CXXALIAS_SYS (wcscspn
, size_t, (const wchar_t *wcs
, const wchar_t *reject
));
949 _GL_CXXALIASWARN (wcscspn
);
951 #elif defined GNULIB_POSIXCHECK
953 # if HAVE_RAW_DECL_WCSCSPN
954 _GL_WARN_ON_USE (wcscspn
, "wcscspn is unportable - "
955 "use gnulib module wcscspn for portability");
960 /* Return the length of the initial segmet of WCS which consists entirely
961 of wide characters in ACCEPT. */
964 _GL_FUNCDECL_SYS (wcsspn
, size_t, (const wchar_t *wcs
, const wchar_t *accept
)
967 _GL_CXXALIAS_SYS (wcsspn
, size_t, (const wchar_t *wcs
, const wchar_t *accept
));
969 _GL_CXXALIASWARN (wcsspn
);
971 #elif defined GNULIB_POSIXCHECK
973 # if HAVE_RAW_DECL_WCSSPN
974 _GL_WARN_ON_USE (wcsspn
, "wcsspn is unportable - "
975 "use gnulib module wcsspn for portability");
980 /* Find the first occurrence in WCS of any character in ACCEPT. */
983 _GL_FUNCDECL_SYS (wcspbrk
, wchar_t *,
984 (const wchar_t *wcs
, const wchar_t *accept
)
987 /* On some systems, this function is defined as an overloaded function:
989 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
990 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
992 _GL_CXXALIAS_SYS_CAST2 (wcspbrk
,
993 wchar_t *, (const wchar_t *, const wchar_t *),
994 const wchar_t *, (const wchar_t *, const wchar_t *));
995 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
996 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
997 _GL_CXXALIASWARN1 (wcspbrk
, wchar_t *,
998 (wchar_t *wcs
, const wchar_t *accept
));
999 _GL_CXXALIASWARN1 (wcspbrk
, const wchar_t *,
1000 (const wchar_t *wcs
, const wchar_t *accept
));
1001 # elif __GLIBC__ >= 2
1002 _GL_CXXALIASWARN (wcspbrk
);
1004 #elif defined GNULIB_POSIXCHECK
1006 # if HAVE_RAW_DECL_WCSPBRK
1007 _GL_WARN_ON_USE (wcspbrk
, "wcspbrk is unportable - "
1008 "use gnulib module wcspbrk for portability");
1013 /* Find the first occurrence of NEEDLE in HAYSTACK. */
1016 _GL_FUNCDECL_SYS (wcsstr
, wchar_t *,
1017 (const wchar_t *haystack
, const wchar_t *needle
)
1018 _GL_ATTRIBUTE_PURE
);
1020 /* On some systems, this function is defined as an overloaded function:
1022 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
1023 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
1025 _GL_CXXALIAS_SYS_CAST2 (wcsstr
,
1026 wchar_t *, (const wchar_t *, const wchar_t *),
1027 const wchar_t *, (const wchar_t *, const wchar_t *));
1028 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1029 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1030 _GL_CXXALIASWARN1 (wcsstr
, wchar_t *,
1031 (wchar_t *haystack
, const wchar_t *needle
));
1032 _GL_CXXALIASWARN1 (wcsstr
, const wchar_t *,
1033 (const wchar_t *haystack
, const wchar_t *needle
));
1034 # elif __GLIBC__ >= 2
1035 _GL_CXXALIASWARN (wcsstr
);
1037 #elif defined GNULIB_POSIXCHECK
1039 # if HAVE_RAW_DECL_WCSSTR
1040 _GL_WARN_ON_USE (wcsstr
, "wcsstr is unportable - "
1041 "use gnulib module wcsstr for portability");
1046 /* Divide WCS into tokens separated by characters in DELIM. */
1048 # if @REPLACE_WCSTOK@
1049 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1051 # define wcstok rpl_wcstok
1053 _GL_FUNCDECL_RPL (wcstok
, wchar_t *,
1054 (wchar_t *wcs
, const wchar_t *delim
, wchar_t **ptr
));
1055 _GL_CXXALIAS_RPL (wcstok
, wchar_t *,
1056 (wchar_t *wcs
, const wchar_t *delim
, wchar_t **ptr
));
1059 _GL_FUNCDECL_SYS (wcstok
, wchar_t *,
1060 (wchar_t *wcs
, const wchar_t *delim
, wchar_t **ptr
));
1062 _GL_CXXALIAS_SYS (wcstok
, wchar_t *,
1063 (wchar_t *wcs
, const wchar_t *delim
, wchar_t **ptr
));
1066 _GL_CXXALIASWARN (wcstok
);
1068 #elif defined GNULIB_POSIXCHECK
1070 # if HAVE_RAW_DECL_WCSTOK
1071 _GL_WARN_ON_USE (wcstok
, "wcstok is unportable - "
1072 "use gnulib module wcstok for portability");
1077 /* Determine number of column positions required for first N wide
1078 characters (or fewer if S ends before this) in S. */
1079 #if @GNULIB_WCSWIDTH@
1080 # if @REPLACE_WCSWIDTH@
1081 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1083 # define wcswidth rpl_wcswidth
1085 _GL_FUNCDECL_RPL (wcswidth
, int, (const wchar_t *s
, size_t n
)
1086 _GL_ATTRIBUTE_PURE
);
1087 _GL_CXXALIAS_RPL (wcswidth
, int, (const wchar_t *s
, size_t n
));
1089 # if !@HAVE_WCSWIDTH@
1090 _GL_FUNCDECL_SYS (wcswidth
, int, (const wchar_t *s
, size_t n
)
1091 _GL_ATTRIBUTE_PURE
);
1093 _GL_CXXALIAS_SYS (wcswidth
, int, (const wchar_t *s
, size_t n
));
1096 _GL_CXXALIASWARN (wcswidth
);
1098 #elif defined GNULIB_POSIXCHECK
1100 # if HAVE_RAW_DECL_WCSWIDTH
1101 _GL_WARN_ON_USE (wcswidth
, "wcswidth is unportable - "
1102 "use gnulib module wcswidth for portability");
1107 /* Convert *TP to a date and time wide string. See
1108 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
1109 #if @GNULIB_WCSFTIME@
1110 # if @REPLACE_WCSFTIME@
1111 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1113 # define wcsftime rpl_wcsftime
1115 _GL_FUNCDECL_RPL (wcsftime
, size_t, (wchar_t *__buf
, size_t __bufsize
,
1116 const wchar_t *__fmt
, const struct tm
*__tp
)
1117 _GL_ARG_NONNULL ((1, 3, 4)));
1118 _GL_CXXALIAS_RPL (wcsftime
, size_t, (wchar_t *__buf
, size_t __bufsize
,
1119 const wchar_t *__fmt
, const struct tm
*__tp
));
1121 # if !@HAVE_WCSFTIME@
1122 _GL_FUNCDECL_SYS (wcsftime
, size_t, (wchar_t *__buf
, size_t __bufsize
,
1123 const wchar_t *__fmt
, const struct tm
*__tp
)
1124 _GL_ARG_NONNULL ((1, 3, 4)));
1126 _GL_CXXALIAS_SYS (wcsftime
, size_t, (wchar_t *__buf
, size_t __bufsize
,
1127 const wchar_t *__fmt
, const struct tm
*__tp
));
1130 _GL_CXXALIASWARN (wcsftime
);
1132 #elif defined GNULIB_POSIXCHECK
1134 # if HAVE_RAW_DECL_WCSFTIME
1135 _GL_WARN_ON_USE (wcsftime
, "wcsftime is unportable - "
1136 "use gnulib module wcsftime for portability");
1141 #endif /* _@GUARD_PREFIX@_WCHAR_H */
1142 #endif /* _@GUARD_PREFIX@_WCHAR_H */