1 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
3 Copyright (C) 2007-2011 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, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 /* Written by Eric Blake. */
22 * ISO C 99 <wchar.h> for platforms that have issues.
23 * <http://www.opengroup.org/susv3xbd/wchar.h.html>
25 * For now, this just ensures proper prerequisite inclusion order and
26 * the declaration of wcwidth().
30 @PRAGMA_SYSTEM_HEADER@
34 #if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H
35 /* Special invocation convention:
36 - Inside glibc and uClibc header files.
37 - On HP-UX 11.00 we have a sequence of nested includes
38 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
39 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
40 and once directly. In both situations 'wint_t' is not yet defined,
41 therefore we cannot provide the function overrides; instead include only
42 the system's <wchar.h>.
43 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
44 the latter includes <wchar.h>. But here, we have no way to detect whether
45 <wctype.h> is completely included or is still being included. */
47 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
50 /* Normal invocation convention. */
52 #ifndef _@GUARD_PREFIX@_WCHAR_H
54 #define _GL_ALREADY_INCLUDING_WCHAR_H
57 # include <features.h> /* for __GLIBC__ */
60 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
62 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
63 included before <wchar.h>.
64 In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
66 But avoid namespace pollution on glibc systems. */
67 #if !(defined __GLIBC__ && !defined __UCLIBC__)
75 /* Include the original <wchar.h> if it exists.
76 Some builds of uClibc lack it. */
77 /* The include_next requires a split double-inclusion guard. */
79 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
82 #undef _GL_ALREADY_INCLUDING_WCHAR_H
84 #ifndef _@GUARD_PREFIX@_WCHAR_H
85 #define _@GUARD_PREFIX@_WCHAR_H
87 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
89 /* The definition of _GL_ARG_NONNULL is copied here. */
91 /* The definition of _GL_WARN_ON_USE is copied here. */
94 /* Define wint_t and WEOF. (Also done in wctype.in.h.) */
95 #if !@HAVE_WINT_T@ && !defined wint_t
101 /* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>.
102 This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be
103 "unchanged by default argument promotions". Override it. */
104 # if defined _MSC_VER
105 # if !GNULIB_defined_wint_t
106 # include <crtdefs.h>
107 typedef unsigned int rpl_wint_t;
109 # define wint_t rpl_wint_t
110 # define GNULIB_defined_wint_t 1
114 # define WEOF ((wint_t) -1)
119 /* Override mbstate_t if it is too small.
120 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
121 implementing mbrtowc for encodings like UTF-8. */
122 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
123 # if !GNULIB_defined_mbstate_t
124 typedef int rpl_mbstate_t;
126 # define mbstate_t rpl_mbstate_t
127 # define GNULIB_defined_mbstate_t 1
132 /* Convert a single-byte character to a wide character. */
135 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
137 # define btowc rpl_btowc
139 _GL_FUNCDECL_RPL (btowc, wint_t, (int c));
140 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
143 _GL_FUNCDECL_SYS (btowc, wint_t, (int c));
145 _GL_CXXALIAS_SYS (btowc, wint_t, (int c));
147 _GL_CXXALIASWARN (btowc);
148 #elif defined GNULIB_POSIXCHECK
150 # if HAVE_RAW_DECL_BTOWC
151 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
152 "use gnulib module btowc for portability");
157 /* Convert a wide character to a single-byte character. */
160 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
162 # define wctob rpl_wctob
164 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc));
165 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
167 # if !defined wctob && !@HAVE_DECL_WCTOB@
168 /* wctob is provided by gnulib, or wctob exists but is not declared. */
169 _GL_FUNCDECL_SYS (wctob, int, (wint_t wc));
171 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
173 _GL_CXXALIASWARN (wctob);
174 #elif defined GNULIB_POSIXCHECK
176 # if HAVE_RAW_DECL_WCTOB
177 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
178 "use gnulib module wctob for portability");
183 /* Test whether *PS is in the initial state. */
185 # if @REPLACE_MBSINIT@
186 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
188 # define mbsinit rpl_mbsinit
190 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
191 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
194 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
196 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
198 _GL_CXXALIASWARN (mbsinit);
199 #elif defined GNULIB_POSIXCHECK
201 # if HAVE_RAW_DECL_MBSINIT
202 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
203 "use gnulib module mbsinit for portability");
208 /* Convert a multibyte character to a wide character. */
210 # if @REPLACE_MBRTOWC@
211 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
213 # define mbrtowc rpl_mbrtowc
215 _GL_FUNCDECL_RPL (mbrtowc, size_t,
216 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
217 _GL_CXXALIAS_RPL (mbrtowc, size_t,
218 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
221 _GL_FUNCDECL_SYS (mbrtowc, size_t,
222 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
224 _GL_CXXALIAS_SYS (mbrtowc, size_t,
225 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
227 _GL_CXXALIASWARN (mbrtowc);
228 #elif defined GNULIB_POSIXCHECK
230 # if HAVE_RAW_DECL_MBRTOWC
231 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
232 "use gnulib module mbrtowc for portability");
237 /* Recognize a multibyte character. */
239 # if @REPLACE_MBRLEN@
240 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
242 # define mbrlen rpl_mbrlen
244 _GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
245 _GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
248 _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
250 _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
252 _GL_CXXALIASWARN (mbrlen);
253 #elif defined GNULIB_POSIXCHECK
255 # if HAVE_RAW_DECL_MBRLEN
256 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
257 "use gnulib module mbrlen for portability");
262 /* Convert a string to a wide string. */
263 #if @GNULIB_MBSRTOWCS@
264 # if @REPLACE_MBSRTOWCS@
265 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
267 # define mbsrtowcs rpl_mbsrtowcs
269 _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
270 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
271 _GL_ARG_NONNULL ((2)));
272 _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
273 (wchar_t *dest, const char **srcp, size_t len,
276 # if !@HAVE_MBSRTOWCS@
277 _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
278 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
279 _GL_ARG_NONNULL ((2)));
281 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
282 (wchar_t *dest, const char **srcp, size_t len,
285 _GL_CXXALIASWARN (mbsrtowcs);
286 #elif defined GNULIB_POSIXCHECK
288 # if HAVE_RAW_DECL_MBSRTOWCS
289 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
290 "use gnulib module mbsrtowcs for portability");
295 /* Convert a string to a wide string. */
296 #if @GNULIB_MBSNRTOWCS@
297 # if @REPLACE_MBSNRTOWCS@
298 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
300 # define mbsnrtowcs rpl_mbsnrtowcs
302 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
303 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
305 _GL_ARG_NONNULL ((2)));
306 _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
307 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
310 # if !@HAVE_MBSNRTOWCS@
311 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
312 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
314 _GL_ARG_NONNULL ((2)));
316 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
317 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
320 _GL_CXXALIASWARN (mbsnrtowcs);
321 #elif defined GNULIB_POSIXCHECK
323 # if HAVE_RAW_DECL_MBSNRTOWCS
324 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
325 "use gnulib module mbsnrtowcs for portability");
330 /* Convert a wide character to a multibyte character. */
332 # if @REPLACE_WCRTOMB@
333 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
335 # define wcrtomb rpl_wcrtomb
337 _GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
338 _GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
341 _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
343 _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
345 _GL_CXXALIASWARN (wcrtomb);
346 #elif defined GNULIB_POSIXCHECK
348 # if HAVE_RAW_DECL_WCRTOMB
349 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
350 "use gnulib module wcrtomb for portability");
355 /* Convert a wide string to a string. */
356 #if @GNULIB_WCSRTOMBS@
357 # if @REPLACE_WCSRTOMBS@
358 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
360 # define wcsrtombs rpl_wcsrtombs
362 _GL_FUNCDECL_RPL (wcsrtombs, size_t,
363 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
364 _GL_ARG_NONNULL ((2)));
365 _GL_CXXALIAS_RPL (wcsrtombs, size_t,
366 (char *dest, const wchar_t **srcp, size_t len,
369 # if !@HAVE_WCSRTOMBS@
370 _GL_FUNCDECL_SYS (wcsrtombs, size_t,
371 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
372 _GL_ARG_NONNULL ((2)));
374 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
375 (char *dest, const wchar_t **srcp, size_t len,
378 _GL_CXXALIASWARN (wcsrtombs);
379 #elif defined GNULIB_POSIXCHECK
381 # if HAVE_RAW_DECL_WCSRTOMBS
382 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
383 "use gnulib module wcsrtombs for portability");
388 /* Convert a wide string to a string. */
389 #if @GNULIB_WCSNRTOMBS@
390 # if @REPLACE_WCSNRTOMBS@
391 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
393 # define wcsnrtombs rpl_wcsnrtombs
395 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
396 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
398 _GL_ARG_NONNULL ((2)));
399 _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
400 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
403 # if !@HAVE_WCSNRTOMBS@
404 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
405 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
407 _GL_ARG_NONNULL ((2)));
409 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
410 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
413 _GL_CXXALIASWARN (wcsnrtombs);
414 #elif defined GNULIB_POSIXCHECK
416 # if HAVE_RAW_DECL_WCSNRTOMBS
417 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
418 "use gnulib module wcsnrtombs for portability");
423 /* Return the number of screen columns needed for WC. */
425 # if @REPLACE_WCWIDTH@
426 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
428 # define wcwidth rpl_wcwidth
430 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t));
431 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
433 # if !@HAVE_DECL_WCWIDTH@
434 /* wcwidth exists but is not declared. */
435 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t));
437 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
439 _GL_CXXALIASWARN (wcwidth);
440 #elif defined GNULIB_POSIXCHECK
442 # if HAVE_RAW_DECL_WCWIDTH
443 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
444 "use gnulib module wcwidth for portability");
449 /* Search N wide characters of S for C. */
452 _GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n));
454 /* On some systems, this function is defined as an overloaded function:
456 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
457 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
459 _GL_CXXALIAS_SYS_CAST2 (wmemchr,
460 wchar_t *, (const wchar_t *, wchar_t, size_t),
461 const wchar_t *, (const wchar_t *, wchar_t, size_t));
462 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
463 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
464 _GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
465 _GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
466 (const wchar_t *s, wchar_t c, size_t n));
468 _GL_CXXALIASWARN (wmemchr);
470 #elif defined GNULIB_POSIXCHECK
472 # if HAVE_RAW_DECL_WMEMCHR
473 _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
474 "use gnulib module wmemchr for portability");
479 /* Compare N wide characters of S1 and S2. */
482 _GL_FUNCDECL_SYS (wmemcmp, int,
483 (const wchar_t *s1, const wchar_t *s2, size_t n));
485 _GL_CXXALIAS_SYS (wmemcmp, int,
486 (const wchar_t *s1, const wchar_t *s2, size_t n));
487 _GL_CXXALIASWARN (wmemcmp);
488 #elif defined GNULIB_POSIXCHECK
490 # if HAVE_RAW_DECL_WMEMCMP
491 _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
492 "use gnulib module wmemcmp for portability");
497 /* Copy N wide characters of SRC to DEST. */
500 _GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
501 (wchar_t *dest, const wchar_t *src, size_t n));
503 _GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
504 (wchar_t *dest, const wchar_t *src, size_t n));
505 _GL_CXXALIASWARN (wmemcpy);
506 #elif defined GNULIB_POSIXCHECK
508 # if HAVE_RAW_DECL_WMEMCPY
509 _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
510 "use gnulib module wmemcpy for portability");
515 /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
516 overlapping memory areas. */
517 #if @GNULIB_WMEMMOVE@
518 # if !@HAVE_WMEMMOVE@
519 _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
520 (wchar_t *dest, const wchar_t *src, size_t n));
522 _GL_CXXALIAS_SYS (wmemmove, wchar_t *,
523 (wchar_t *dest, const wchar_t *src, size_t n));
524 _GL_CXXALIASWARN (wmemmove);
525 #elif defined GNULIB_POSIXCHECK
527 # if HAVE_RAW_DECL_WMEMMOVE
528 _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
529 "use gnulib module wmemmove for portability");
534 /* Set N wide characters of S to C. */
537 _GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
539 _GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
540 _GL_CXXALIASWARN (wmemset);
541 #elif defined GNULIB_POSIXCHECK
543 # if HAVE_RAW_DECL_WMEMSET
544 _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
545 "use gnulib module wmemset for portability");
550 /* Return the number of wide characters in S. */
553 _GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s));
555 _GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
556 _GL_CXXALIASWARN (wcslen);
557 #elif defined GNULIB_POSIXCHECK
559 # if HAVE_RAW_DECL_WCSLEN
560 _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
561 "use gnulib module wcslen for portability");
566 /* Return the number of wide characters in S, but at most MAXLEN. */
569 _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
571 _GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
572 _GL_CXXALIASWARN (wcsnlen);
573 #elif defined GNULIB_POSIXCHECK
575 # if HAVE_RAW_DECL_WCSNLEN
576 _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
577 "use gnulib module wcsnlen for portability");
582 /* Copy SRC to DEST. */
585 _GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
587 _GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
588 _GL_CXXALIASWARN (wcscpy);
589 #elif defined GNULIB_POSIXCHECK
591 # if HAVE_RAW_DECL_WCSCPY
592 _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
593 "use gnulib module wcscpy for portability");
598 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
601 _GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
603 _GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
604 _GL_CXXALIASWARN (wcpcpy);
605 #elif defined GNULIB_POSIXCHECK
607 # if HAVE_RAW_DECL_WCPCPY
608 _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
609 "use gnulib module wcpcpy for portability");
614 /* Copy no more than N wide characters of SRC to DEST. */
617 _GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
618 (wchar_t *dest, const wchar_t *src, size_t n));
620 _GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
621 (wchar_t *dest, const wchar_t *src, size_t n));
622 _GL_CXXALIASWARN (wcsncpy);
623 #elif defined GNULIB_POSIXCHECK
625 # if HAVE_RAW_DECL_WCSNCPY
626 _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
627 "use gnulib module wcsncpy for portability");
632 /* Copy no more than N characters of SRC to DEST, returning the address of
633 the last character written into DEST. */
636 _GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
637 (wchar_t *dest, const wchar_t *src, size_t n));
639 _GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
640 (wchar_t *dest, const wchar_t *src, size_t n));
641 _GL_CXXALIASWARN (wcpncpy);
642 #elif defined GNULIB_POSIXCHECK
644 # if HAVE_RAW_DECL_WCPNCPY
645 _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
646 "use gnulib module wcpncpy for portability");
651 /* Append SRC onto DEST. */
654 _GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
656 _GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
657 _GL_CXXALIASWARN (wcscat);
658 #elif defined GNULIB_POSIXCHECK
660 # if HAVE_RAW_DECL_WCSCAT
661 _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
662 "use gnulib module wcscat for portability");
667 /* Append no more than N wide characters of SRC onto DEST. */
670 _GL_FUNCDECL_SYS (wcsncat, wchar_t *,
671 (wchar_t *dest, const wchar_t *src, size_t n));
673 _GL_CXXALIAS_SYS (wcsncat, wchar_t *,
674 (wchar_t *dest, const wchar_t *src, size_t n));
675 _GL_CXXALIASWARN (wcsncat);
676 #elif defined GNULIB_POSIXCHECK
678 # if HAVE_RAW_DECL_WCSNCAT
679 _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
680 "use gnulib module wcsncat for portability");
685 /* Compare S1 and S2. */
688 _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
690 _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
691 _GL_CXXALIASWARN (wcscmp);
692 #elif defined GNULIB_POSIXCHECK
694 # if HAVE_RAW_DECL_WCSCMP
695 _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
696 "use gnulib module wcscmp for portability");
701 /* Compare no more than N wide characters of S1 and S2. */
704 _GL_FUNCDECL_SYS (wcsncmp, int,
705 (const wchar_t *s1, const wchar_t *s2, size_t n));
707 _GL_CXXALIAS_SYS (wcsncmp, int,
708 (const wchar_t *s1, const wchar_t *s2, size_t n));
709 _GL_CXXALIASWARN (wcsncmp);
710 #elif defined GNULIB_POSIXCHECK
712 # if HAVE_RAW_DECL_WCSNCMP
713 _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
714 "use gnulib module wcsncmp for portability");
719 /* Compare S1 and S2, ignoring case. */
720 #if @GNULIB_WCSCASECMP@
721 # if !@HAVE_WCSCASECMP@
722 _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
724 _GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
725 _GL_CXXALIASWARN (wcscasecmp);
726 #elif defined GNULIB_POSIXCHECK
728 # if HAVE_RAW_DECL_WCSCASECMP
729 _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
730 "use gnulib module wcscasecmp for portability");
735 /* Compare no more than N chars of S1 and S2, ignoring case. */
736 #if @GNULIB_WCSNCASECMP@
737 # if !@HAVE_WCSNCASECMP@
738 _GL_FUNCDECL_SYS (wcsncasecmp, int,
739 (const wchar_t *s1, const wchar_t *s2, size_t n));
741 _GL_CXXALIAS_SYS (wcsncasecmp, int,
742 (const wchar_t *s1, const wchar_t *s2, size_t n));
743 _GL_CXXALIASWARN (wcsncasecmp);
744 #elif defined GNULIB_POSIXCHECK
746 # if HAVE_RAW_DECL_WCSNCASECMP
747 _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
748 "use gnulib module wcsncasecmp for portability");
753 /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
754 category of the current locale. */
757 _GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
759 _GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
760 _GL_CXXALIASWARN (wcscoll);
761 #elif defined GNULIB_POSIXCHECK
763 # if HAVE_RAW_DECL_WCSCOLL
764 _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
765 "use gnulib module wcscoll for portability");
770 /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
771 to two transformed strings the result is the as applying 'wcscoll' to the
775 _GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
777 _GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
778 _GL_CXXALIASWARN (wcsxfrm);
779 #elif defined GNULIB_POSIXCHECK
781 # if HAVE_RAW_DECL_WCSXFRM
782 _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
783 "use gnulib module wcsxfrm for portability");
788 /* Duplicate S, returning an identical malloc'd string. */
791 _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s));
793 _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
794 _GL_CXXALIASWARN (wcsdup);
795 #elif defined GNULIB_POSIXCHECK
797 # if HAVE_RAW_DECL_WCSDUP
798 _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
799 "use gnulib module wcsdup for portability");
804 /* Find the first occurrence of WC in WCS. */
807 _GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
809 /* On some systems, this function is defined as an overloaded function:
811 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
812 wchar_t * std::wcschr (wchar_t *, wchar_t);
814 _GL_CXXALIAS_SYS_CAST2 (wcschr,
815 wchar_t *, (const wchar_t *, wchar_t),
816 const wchar_t *, (const wchar_t *, wchar_t));
817 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
818 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
819 _GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
820 _GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
822 _GL_CXXALIASWARN (wcschr);
824 #elif defined GNULIB_POSIXCHECK
826 # if HAVE_RAW_DECL_WCSCHR
827 _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
828 "use gnulib module wcschr for portability");
833 /* Find the last occurrence of WC in WCS. */
836 _GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
838 /* On some systems, this function is defined as an overloaded function:
840 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
841 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
843 _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
844 wchar_t *, (const wchar_t *, wchar_t),
845 const wchar_t *, (const wchar_t *, wchar_t));
846 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
847 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
848 _GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
849 _GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
851 _GL_CXXALIASWARN (wcsrchr);
853 #elif defined GNULIB_POSIXCHECK
855 # if HAVE_RAW_DECL_WCSRCHR
856 _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
857 "use gnulib module wcsrchr for portability");
862 /* Return the length of the initial segmet of WCS which consists entirely
863 of wide characters not in REJECT. */
866 _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
868 _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
869 _GL_CXXALIASWARN (wcscspn);
870 #elif defined GNULIB_POSIXCHECK
872 # if HAVE_RAW_DECL_WCSCSPN
873 _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
874 "use gnulib module wcscspn for portability");
879 /* Return the length of the initial segmet of WCS which consists entirely
880 of wide characters in ACCEPT. */
883 _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
885 _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
886 _GL_CXXALIASWARN (wcsspn);
887 #elif defined GNULIB_POSIXCHECK
889 # if HAVE_RAW_DECL_WCSSPN
890 _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
891 "use gnulib module wcsspn for portability");
896 /* Find the first occurrence in WCS of any character in ACCEPT. */
899 _GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
900 (const wchar_t *wcs, const wchar_t *accept));
902 /* On some systems, this function is defined as an overloaded function:
904 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
905 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
907 _GL_CXXALIAS_SYS_CAST2 (wcspbrk,
908 wchar_t *, (const wchar_t *, const wchar_t *),
909 const wchar_t *, (const wchar_t *, const wchar_t *));
910 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
911 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
912 _GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
913 (wchar_t *wcs, const wchar_t *accept));
914 _GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
915 (const wchar_t *wcs, const wchar_t *accept));
917 _GL_CXXALIASWARN (wcspbrk);
919 #elif defined GNULIB_POSIXCHECK
921 # if HAVE_RAW_DECL_WCSPBRK
922 _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
923 "use gnulib module wcspbrk for portability");
928 /* Find the first occurrence of NEEDLE in HAYSTACK. */
931 _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
932 (const wchar_t *haystack, const wchar_t *needle));
934 /* On some systems, this function is defined as an overloaded function:
936 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
937 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
939 _GL_CXXALIAS_SYS_CAST2 (wcsstr,
940 wchar_t *, (const wchar_t *, const wchar_t *),
941 const wchar_t *, (const wchar_t *, const wchar_t *));
942 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
943 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
944 _GL_CXXALIASWARN1 (wcsstr, wchar_t *,
945 (wchar_t *haystack, const wchar_t *needle));
946 _GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
947 (const wchar_t *haystack, const wchar_t *needle));
949 _GL_CXXALIASWARN (wcsstr);
951 #elif defined GNULIB_POSIXCHECK
953 # if HAVE_RAW_DECL_WCSSTR
954 _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
955 "use gnulib module wcsstr for portability");
960 /* Divide WCS into tokens separated by characters in DELIM. */
963 _GL_FUNCDECL_SYS (wcstok, wchar_t *,
964 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
966 _GL_CXXALIAS_SYS (wcstok, wchar_t *,
967 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
968 _GL_CXXALIASWARN (wcstok);
969 #elif defined GNULIB_POSIXCHECK
971 # if HAVE_RAW_DECL_WCSTOK
972 _GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
973 "use gnulib module wcstok for portability");
978 /* Determine number of column positions required for first N wide
979 characters (or fewer if S ends before this) in S. */
980 #if @GNULIB_WCSWIDTH@
981 # if @REPLACE_WCSWIDTH@
982 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
984 # define wcswidth rpl_wcswidth
986 _GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n));
987 _GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
989 # if !@HAVE_WCSWIDTH@
990 _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n));
992 _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
994 _GL_CXXALIASWARN (wcswidth);
995 #elif defined GNULIB_POSIXCHECK
997 # if HAVE_RAW_DECL_WCSWIDTH
998 _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
999 "use gnulib module wcswidth for portability");
1004 #endif /* _@GUARD_PREFIX@_WCHAR_H */
1005 #endif /* _@GUARD_PREFIX@_WCHAR_H */