1 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
3 Copyright (C) 2007-2015 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 <http://www.gnu.org/licenses/>. */
18 /* Written by Eric Blake. */
21 * ISO C 99 <wchar.h> for platforms that have issues.
22 * <http://www.opengroup.org/susv3xbd/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 _GL_ALREADY_INCLUDING_WCHAR_H)
39 /* Special invocation convention:
40 - Inside glibc and uClibc header files, but not MinGW.
41 - On HP-UX 11.00 we have a sequence of nested includes
42 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
43 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
44 and once directly. In both situations 'wint_t' is not yet defined,
45 therefore we cannot provide the function overrides; instead include only
46 the system's <wchar.h>.
47 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
48 the latter includes <wchar.h>. But here, we have no way to detect whether
49 <wctype.h> is completely included or is still being included. */
51 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
54 /* Normal invocation convention. */
56 #ifndef _@GUARD_PREFIX@_WCHAR_H
58 #define _GL_ALREADY_INCLUDING_WCHAR_H
61 # include <features.h> /* for __GLIBC__ */
64 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
66 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
67 included before <wchar.h>.
68 In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
70 But avoid namespace pollution on glibc systems. */
71 #if !(defined __GLIBC__ && !defined __UCLIBC__)
79 /* Include the original <wchar.h> if it exists.
80 Some builds of uClibc lack it. */
81 /* The include_next requires a split double-inclusion guard. */
83 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
86 #undef _GL_ALREADY_INCLUDING_WCHAR_H
88 #ifndef _@GUARD_PREFIX@_WCHAR_H
89 #define _@GUARD_PREFIX@_WCHAR_H
91 /* The __attribute__ feature is available in gcc versions 2.5 and later.
92 The attribute __pure__ was added in gcc 2.96. */
93 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
94 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
96 # define _GL_ATTRIBUTE_PURE /* empty */
99 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
101 /* The definition of _GL_ARG_NONNULL is copied here. */
103 /* The definition of _GL_WARN_ON_USE is copied here. */
106 /* Define wint_t and WEOF. (Also done in wctype.in.h.) */
107 #if !@HAVE_WINT_T@ && !defined wint_t
113 /* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>.
114 This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be
115 "unchanged by default argument promotions". Override it. */
116 # if defined _MSC_VER
117 # if !GNULIB_defined_wint_t
118 # include <crtdefs.h>
119 typedef unsigned int rpl_wint_t;
121 # define wint_t rpl_wint_t
122 # define GNULIB_defined_wint_t 1
126 # define WEOF ((wint_t) -1)
131 /* Override mbstate_t if it is too small.
132 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
133 implementing mbrtowc for encodings like UTF-8. */
134 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
135 # if !GNULIB_defined_mbstate_t
136 typedef int rpl_mbstate_t;
138 # define mbstate_t rpl_mbstate_t
139 # define GNULIB_defined_mbstate_t 1
144 /* Convert a single-byte character to a wide character. */
147 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
149 # define btowc rpl_btowc
151 _GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
152 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
155 _GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
157 _GL_CXXALIAS_SYS (btowc, wint_t, (int c));
159 _GL_CXXALIASWARN (btowc);
160 #elif defined GNULIB_POSIXCHECK
162 # if HAVE_RAW_DECL_BTOWC
163 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
164 "use gnulib module btowc for portability");
169 /* Convert a wide character to a single-byte character. */
172 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
174 # define wctob rpl_wctob
176 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
177 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
179 # if !defined wctob && !@HAVE_DECL_WCTOB@
180 /* wctob is provided by gnulib, or wctob exists but is not declared. */
181 _GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
183 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
185 _GL_CXXALIASWARN (wctob);
186 #elif defined GNULIB_POSIXCHECK
188 # if HAVE_RAW_DECL_WCTOB
189 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
190 "use gnulib module wctob for portability");
195 /* Test whether *PS is in the initial state. */
197 # if @REPLACE_MBSINIT@
198 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
200 # define mbsinit rpl_mbsinit
202 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
203 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
206 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
208 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
210 _GL_CXXALIASWARN (mbsinit);
211 #elif defined GNULIB_POSIXCHECK
213 # if HAVE_RAW_DECL_MBSINIT
214 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
215 "use gnulib module mbsinit for portability");
220 /* Convert a multibyte character to a wide character. */
222 # if @REPLACE_MBRTOWC@
223 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
225 # define mbrtowc rpl_mbrtowc
227 _GL_FUNCDECL_RPL (mbrtowc, size_t,
228 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
229 _GL_CXXALIAS_RPL (mbrtowc, size_t,
230 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
233 _GL_FUNCDECL_SYS (mbrtowc, size_t,
234 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
236 _GL_CXXALIAS_SYS (mbrtowc, size_t,
237 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
239 _GL_CXXALIASWARN (mbrtowc);
240 #elif defined GNULIB_POSIXCHECK
242 # if HAVE_RAW_DECL_MBRTOWC
243 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
244 "use gnulib module mbrtowc for portability");
249 /* Recognize a multibyte character. */
251 # if @REPLACE_MBRLEN@
252 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
254 # define mbrlen rpl_mbrlen
256 _GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
257 _GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
260 _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
262 _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
264 _GL_CXXALIASWARN (mbrlen);
265 #elif defined GNULIB_POSIXCHECK
267 # if HAVE_RAW_DECL_MBRLEN
268 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
269 "use gnulib module mbrlen for portability");
274 /* Convert a string to a wide string. */
275 #if @GNULIB_MBSRTOWCS@
276 # if @REPLACE_MBSRTOWCS@
277 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
279 # define mbsrtowcs rpl_mbsrtowcs
281 _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
282 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
283 _GL_ARG_NONNULL ((2)));
284 _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
285 (wchar_t *dest, const char **srcp, size_t len,
288 # if !@HAVE_MBSRTOWCS@
289 _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
290 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
291 _GL_ARG_NONNULL ((2)));
293 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
294 (wchar_t *dest, const char **srcp, size_t len,
297 _GL_CXXALIASWARN (mbsrtowcs);
298 #elif defined GNULIB_POSIXCHECK
300 # if HAVE_RAW_DECL_MBSRTOWCS
301 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
302 "use gnulib module mbsrtowcs for portability");
307 /* Convert a string to a wide string. */
308 #if @GNULIB_MBSNRTOWCS@
309 # if @REPLACE_MBSNRTOWCS@
310 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
312 # define mbsnrtowcs rpl_mbsnrtowcs
314 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
315 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
317 _GL_ARG_NONNULL ((2)));
318 _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
319 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
322 # if !@HAVE_MBSNRTOWCS@
323 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
324 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
326 _GL_ARG_NONNULL ((2)));
328 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
329 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
332 _GL_CXXALIASWARN (mbsnrtowcs);
333 #elif defined GNULIB_POSIXCHECK
335 # if HAVE_RAW_DECL_MBSNRTOWCS
336 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
337 "use gnulib module mbsnrtowcs for portability");
342 /* Convert a wide character to a multibyte character. */
344 # if @REPLACE_WCRTOMB@
345 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
347 # define wcrtomb rpl_wcrtomb
349 _GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
350 _GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
353 _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
355 _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
357 _GL_CXXALIASWARN (wcrtomb);
358 #elif defined GNULIB_POSIXCHECK
360 # if HAVE_RAW_DECL_WCRTOMB
361 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
362 "use gnulib module wcrtomb for portability");
367 /* Convert a wide string to a string. */
368 #if @GNULIB_WCSRTOMBS@
369 # if @REPLACE_WCSRTOMBS@
370 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
372 # define wcsrtombs rpl_wcsrtombs
374 _GL_FUNCDECL_RPL (wcsrtombs, size_t,
375 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
376 _GL_ARG_NONNULL ((2)));
377 _GL_CXXALIAS_RPL (wcsrtombs, size_t,
378 (char *dest, const wchar_t **srcp, size_t len,
381 # if !@HAVE_WCSRTOMBS@
382 _GL_FUNCDECL_SYS (wcsrtombs, size_t,
383 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
384 _GL_ARG_NONNULL ((2)));
386 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
387 (char *dest, const wchar_t **srcp, size_t len,
390 _GL_CXXALIASWARN (wcsrtombs);
391 #elif defined GNULIB_POSIXCHECK
393 # if HAVE_RAW_DECL_WCSRTOMBS
394 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
395 "use gnulib module wcsrtombs for portability");
400 /* Convert a wide string to a string. */
401 #if @GNULIB_WCSNRTOMBS@
402 # if @REPLACE_WCSNRTOMBS@
403 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
405 # define wcsnrtombs rpl_wcsnrtombs
407 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
408 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
410 _GL_ARG_NONNULL ((2)));
411 _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
412 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
415 # if !@HAVE_WCSNRTOMBS@
416 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
417 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
419 _GL_ARG_NONNULL ((2)));
421 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
422 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
425 _GL_CXXALIASWARN (wcsnrtombs);
426 #elif defined GNULIB_POSIXCHECK
428 # if HAVE_RAW_DECL_WCSNRTOMBS
429 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
430 "use gnulib module wcsnrtombs for portability");
435 /* Return the number of screen columns needed for WC. */
437 # if @REPLACE_WCWIDTH@
438 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
440 # define wcwidth rpl_wcwidth
442 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
443 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
445 # if !@HAVE_DECL_WCWIDTH@
446 /* wcwidth exists but is not declared. */
447 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
449 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
451 _GL_CXXALIASWARN (wcwidth);
452 #elif defined GNULIB_POSIXCHECK
454 # if HAVE_RAW_DECL_WCWIDTH
455 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
456 "use gnulib module wcwidth for portability");
461 /* Search N wide characters of S for C. */
464 _GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n)
467 /* On some systems, this function is defined as an overloaded function:
469 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
470 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
472 _GL_CXXALIAS_SYS_CAST2 (wmemchr,
473 wchar_t *, (const wchar_t *, wchar_t, size_t),
474 const wchar_t *, (const wchar_t *, wchar_t, size_t));
475 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
476 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
477 _GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
478 _GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
479 (const wchar_t *s, wchar_t c, size_t n));
481 _GL_CXXALIASWARN (wmemchr);
483 #elif defined GNULIB_POSIXCHECK
485 # if HAVE_RAW_DECL_WMEMCHR
486 _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
487 "use gnulib module wmemchr for portability");
492 /* Compare N wide characters of S1 and S2. */
495 _GL_FUNCDECL_SYS (wmemcmp, int,
496 (const wchar_t *s1, const wchar_t *s2, size_t n)
499 _GL_CXXALIAS_SYS (wmemcmp, int,
500 (const wchar_t *s1, const wchar_t *s2, size_t n));
501 _GL_CXXALIASWARN (wmemcmp);
502 #elif defined GNULIB_POSIXCHECK
504 # if HAVE_RAW_DECL_WMEMCMP
505 _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
506 "use gnulib module wmemcmp for portability");
511 /* Copy N wide characters of SRC to DEST. */
514 _GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
515 (wchar_t *dest, const wchar_t *src, size_t n));
517 _GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
518 (wchar_t *dest, const wchar_t *src, size_t n));
519 _GL_CXXALIASWARN (wmemcpy);
520 #elif defined GNULIB_POSIXCHECK
522 # if HAVE_RAW_DECL_WMEMCPY
523 _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
524 "use gnulib module wmemcpy for portability");
529 /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
530 overlapping memory areas. */
531 #if @GNULIB_WMEMMOVE@
532 # if !@HAVE_WMEMMOVE@
533 _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
534 (wchar_t *dest, const wchar_t *src, size_t n));
536 _GL_CXXALIAS_SYS (wmemmove, wchar_t *,
537 (wchar_t *dest, const wchar_t *src, size_t n));
538 _GL_CXXALIASWARN (wmemmove);
539 #elif defined GNULIB_POSIXCHECK
541 # if HAVE_RAW_DECL_WMEMMOVE
542 _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
543 "use gnulib module wmemmove for portability");
548 /* Set N wide characters of S to C. */
551 _GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
553 _GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
554 _GL_CXXALIASWARN (wmemset);
555 #elif defined GNULIB_POSIXCHECK
557 # if HAVE_RAW_DECL_WMEMSET
558 _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
559 "use gnulib module wmemset for portability");
564 /* Return the number of wide characters in S. */
567 _GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE);
569 _GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
570 _GL_CXXALIASWARN (wcslen);
571 #elif defined GNULIB_POSIXCHECK
573 # if HAVE_RAW_DECL_WCSLEN
574 _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
575 "use gnulib module wcslen for portability");
580 /* Return the number of wide characters in S, but at most MAXLEN. */
583 _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)
586 _GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
587 _GL_CXXALIASWARN (wcsnlen);
588 #elif defined GNULIB_POSIXCHECK
590 # if HAVE_RAW_DECL_WCSNLEN
591 _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
592 "use gnulib module wcsnlen for portability");
597 /* Copy SRC to DEST. */
600 _GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
602 _GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
603 _GL_CXXALIASWARN (wcscpy);
604 #elif defined GNULIB_POSIXCHECK
606 # if HAVE_RAW_DECL_WCSCPY
607 _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
608 "use gnulib module wcscpy for portability");
613 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
616 _GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
618 _GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
619 _GL_CXXALIASWARN (wcpcpy);
620 #elif defined GNULIB_POSIXCHECK
622 # if HAVE_RAW_DECL_WCPCPY
623 _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
624 "use gnulib module wcpcpy for portability");
629 /* Copy no more than N wide characters of SRC to DEST. */
632 _GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
633 (wchar_t *dest, const wchar_t *src, size_t n));
635 _GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
636 (wchar_t *dest, const wchar_t *src, size_t n));
637 _GL_CXXALIASWARN (wcsncpy);
638 #elif defined GNULIB_POSIXCHECK
640 # if HAVE_RAW_DECL_WCSNCPY
641 _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
642 "use gnulib module wcsncpy for portability");
647 /* Copy no more than N characters of SRC to DEST, returning the address of
648 the last character written into DEST. */
651 _GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
652 (wchar_t *dest, const wchar_t *src, size_t n));
654 _GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
655 (wchar_t *dest, const wchar_t *src, size_t n));
656 _GL_CXXALIASWARN (wcpncpy);
657 #elif defined GNULIB_POSIXCHECK
659 # if HAVE_RAW_DECL_WCPNCPY
660 _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
661 "use gnulib module wcpncpy for portability");
666 /* Append SRC onto DEST. */
669 _GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
671 _GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
672 _GL_CXXALIASWARN (wcscat);
673 #elif defined GNULIB_POSIXCHECK
675 # if HAVE_RAW_DECL_WCSCAT
676 _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
677 "use gnulib module wcscat for portability");
682 /* Append no more than N wide characters of SRC onto DEST. */
685 _GL_FUNCDECL_SYS (wcsncat, wchar_t *,
686 (wchar_t *dest, const wchar_t *src, size_t n));
688 _GL_CXXALIAS_SYS (wcsncat, wchar_t *,
689 (wchar_t *dest, const wchar_t *src, size_t n));
690 _GL_CXXALIASWARN (wcsncat);
691 #elif defined GNULIB_POSIXCHECK
693 # if HAVE_RAW_DECL_WCSNCAT
694 _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
695 "use gnulib module wcsncat for portability");
700 /* Compare S1 and S2. */
703 _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)
706 _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
707 _GL_CXXALIASWARN (wcscmp);
708 #elif defined GNULIB_POSIXCHECK
710 # if HAVE_RAW_DECL_WCSCMP
711 _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
712 "use gnulib module wcscmp for portability");
717 /* Compare no more than N wide characters of S1 and S2. */
720 _GL_FUNCDECL_SYS (wcsncmp, int,
721 (const wchar_t *s1, const wchar_t *s2, size_t n)
724 _GL_CXXALIAS_SYS (wcsncmp, int,
725 (const wchar_t *s1, const wchar_t *s2, size_t n));
726 _GL_CXXALIASWARN (wcsncmp);
727 #elif defined GNULIB_POSIXCHECK
729 # if HAVE_RAW_DECL_WCSNCMP
730 _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
731 "use gnulib module wcsncmp for portability");
736 /* Compare S1 and S2, ignoring case. */
737 #if @GNULIB_WCSCASECMP@
738 # if !@HAVE_WCSCASECMP@
739 _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)
742 _GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
743 _GL_CXXALIASWARN (wcscasecmp);
744 #elif defined GNULIB_POSIXCHECK
746 # if HAVE_RAW_DECL_WCSCASECMP
747 _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
748 "use gnulib module wcscasecmp for portability");
753 /* Compare no more than N chars of S1 and S2, ignoring case. */
754 #if @GNULIB_WCSNCASECMP@
755 # if !@HAVE_WCSNCASECMP@
756 _GL_FUNCDECL_SYS (wcsncasecmp, int,
757 (const wchar_t *s1, const wchar_t *s2, size_t n)
760 _GL_CXXALIAS_SYS (wcsncasecmp, int,
761 (const wchar_t *s1, const wchar_t *s2, size_t n));
762 _GL_CXXALIASWARN (wcsncasecmp);
763 #elif defined GNULIB_POSIXCHECK
765 # if HAVE_RAW_DECL_WCSNCASECMP
766 _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
767 "use gnulib module wcsncasecmp for portability");
772 /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
773 category of the current locale. */
776 _GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
778 _GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
779 _GL_CXXALIASWARN (wcscoll);
780 #elif defined GNULIB_POSIXCHECK
782 # if HAVE_RAW_DECL_WCSCOLL
783 _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
784 "use gnulib module wcscoll for portability");
789 /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
790 to two transformed strings the result is the as applying 'wcscoll' to the
794 _GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
796 _GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
797 _GL_CXXALIASWARN (wcsxfrm);
798 #elif defined GNULIB_POSIXCHECK
800 # if HAVE_RAW_DECL_WCSXFRM
801 _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
802 "use gnulib module wcsxfrm for portability");
807 /* Duplicate S, returning an identical malloc'd string. */
810 _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s));
812 _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
813 _GL_CXXALIASWARN (wcsdup);
814 #elif defined GNULIB_POSIXCHECK
816 # if HAVE_RAW_DECL_WCSDUP
817 _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
818 "use gnulib module wcsdup for portability");
823 /* Find the first occurrence of WC in WCS. */
826 _GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
829 /* On some systems, this function is defined as an overloaded function:
831 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
832 wchar_t * std::wcschr (wchar_t *, wchar_t);
834 _GL_CXXALIAS_SYS_CAST2 (wcschr,
835 wchar_t *, (const wchar_t *, wchar_t),
836 const wchar_t *, (const wchar_t *, wchar_t));
837 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
838 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
839 _GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
840 _GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
842 _GL_CXXALIASWARN (wcschr);
844 #elif defined GNULIB_POSIXCHECK
846 # if HAVE_RAW_DECL_WCSCHR
847 _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
848 "use gnulib module wcschr for portability");
853 /* Find the last occurrence of WC in WCS. */
856 _GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
859 /* On some systems, this function is defined as an overloaded function:
861 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
862 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
864 _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
865 wchar_t *, (const wchar_t *, wchar_t),
866 const wchar_t *, (const wchar_t *, wchar_t));
867 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
868 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
869 _GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
870 _GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
872 _GL_CXXALIASWARN (wcsrchr);
874 #elif defined GNULIB_POSIXCHECK
876 # if HAVE_RAW_DECL_WCSRCHR
877 _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
878 "use gnulib module wcsrchr for portability");
883 /* Return the length of the initial segmet of WCS which consists entirely
884 of wide characters not in REJECT. */
887 _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)
890 _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
891 _GL_CXXALIASWARN (wcscspn);
892 #elif defined GNULIB_POSIXCHECK
894 # if HAVE_RAW_DECL_WCSCSPN
895 _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
896 "use gnulib module wcscspn for portability");
901 /* Return the length of the initial segmet of WCS which consists entirely
902 of wide characters in ACCEPT. */
905 _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)
908 _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
909 _GL_CXXALIASWARN (wcsspn);
910 #elif defined GNULIB_POSIXCHECK
912 # if HAVE_RAW_DECL_WCSSPN
913 _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
914 "use gnulib module wcsspn for portability");
919 /* Find the first occurrence in WCS of any character in ACCEPT. */
922 _GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
923 (const wchar_t *wcs, const wchar_t *accept)
926 /* On some systems, this function is defined as an overloaded function:
928 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
929 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
931 _GL_CXXALIAS_SYS_CAST2 (wcspbrk,
932 wchar_t *, (const wchar_t *, const wchar_t *),
933 const wchar_t *, (const wchar_t *, const wchar_t *));
934 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
935 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
936 _GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
937 (wchar_t *wcs, const wchar_t *accept));
938 _GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
939 (const wchar_t *wcs, const wchar_t *accept));
941 _GL_CXXALIASWARN (wcspbrk);
943 #elif defined GNULIB_POSIXCHECK
945 # if HAVE_RAW_DECL_WCSPBRK
946 _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
947 "use gnulib module wcspbrk for portability");
952 /* Find the first occurrence of NEEDLE in HAYSTACK. */
955 _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
956 (const wchar_t *haystack, const wchar_t *needle)
959 /* On some systems, this function is defined as an overloaded function:
961 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
962 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
964 _GL_CXXALIAS_SYS_CAST2 (wcsstr,
965 wchar_t *, (const wchar_t *, const wchar_t *),
966 const wchar_t *, (const wchar_t *, const wchar_t *));
967 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
968 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
969 _GL_CXXALIASWARN1 (wcsstr, wchar_t *,
970 (wchar_t *haystack, const wchar_t *needle));
971 _GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
972 (const wchar_t *haystack, const wchar_t *needle));
974 _GL_CXXALIASWARN (wcsstr);
976 #elif defined GNULIB_POSIXCHECK
978 # if HAVE_RAW_DECL_WCSSTR
979 _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
980 "use gnulib module wcsstr for portability");
985 /* Divide WCS into tokens separated by characters in DELIM. */
988 _GL_FUNCDECL_SYS (wcstok, wchar_t *,
989 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
991 _GL_CXXALIAS_SYS (wcstok, wchar_t *,
992 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
993 _GL_CXXALIASWARN (wcstok);
994 #elif defined GNULIB_POSIXCHECK
996 # if HAVE_RAW_DECL_WCSTOK
997 _GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
998 "use gnulib module wcstok for portability");
1003 /* Determine number of column positions required for first N wide
1004 characters (or fewer if S ends before this) in S. */
1005 #if @GNULIB_WCSWIDTH@
1006 # if @REPLACE_WCSWIDTH@
1007 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1009 # define wcswidth rpl_wcswidth
1011 _GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n)
1012 _GL_ATTRIBUTE_PURE);
1013 _GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
1015 # if !@HAVE_WCSWIDTH@
1016 _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n)
1017 _GL_ATTRIBUTE_PURE);
1019 _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
1021 _GL_CXXALIASWARN (wcswidth);
1022 #elif defined GNULIB_POSIXCHECK
1024 # if HAVE_RAW_DECL_WCSWIDTH
1025 _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1026 "use gnulib module wcswidth for portability");
1031 #endif /* _@GUARD_PREFIX@_WCHAR_H */
1032 #endif /* _@GUARD_PREFIX@_WCHAR_H */