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. */
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 But avoid namespace pollution on glibc systems. */
71 /* Include the original <wchar.h> if it exists.
72 Some builds of uClibc lack it. */
73 /* The include_next requires a split double-inclusion guard. */
75 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
78 #undef _GL_ALREADY_INCLUDING_WCHAR_H
83 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
85 /* The definition of _GL_ARG_NONNULL is copied here. */
87 /* The definition of _GL_WARN_ON_USE is copied here. */
90 /* Define wint_t and WEOF. (Also done in wctype.in.h.) */
91 #if !@HAVE_WINT_T@ && !defined wint_t
98 # define WEOF ((wint_t) -1)
103 /* Override mbstate_t if it is too small.
104 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
105 implementing mbrtowc for encodings like UTF-8. */
106 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
107 # if !GNULIB_defined_mbstate_t
108 typedef int rpl_mbstate_t;
110 # define mbstate_t rpl_mbstate_t
111 # define GNULIB_defined_mbstate_t 1
116 /* Convert a single-byte character to a wide character. */
119 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
121 # define btowc rpl_btowc
123 _GL_FUNCDECL_RPL (btowc, wint_t, (int c));
124 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
127 _GL_FUNCDECL_SYS (btowc, wint_t, (int c));
129 _GL_CXXALIAS_SYS (btowc, wint_t, (int c));
131 _GL_CXXALIASWARN (btowc);
132 #elif defined GNULIB_POSIXCHECK
134 # if HAVE_RAW_DECL_BTOWC
135 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
136 "use gnulib module btowc for portability");
141 /* Convert a wide character to a single-byte character. */
144 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
146 # define wctob rpl_wctob
148 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc));
149 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
151 # if !defined wctob && !@HAVE_DECL_WCTOB@
152 /* wctob is provided by gnulib, or wctob exists but is not declared. */
153 _GL_FUNCDECL_SYS (wctob, int, (wint_t wc));
155 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
157 _GL_CXXALIASWARN (wctob);
158 #elif defined GNULIB_POSIXCHECK
160 # if HAVE_RAW_DECL_WCTOB
161 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
162 "use gnulib module wctob for portability");
167 /* Test whether *PS is in the initial state. */
169 # if @REPLACE_MBSINIT@
170 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
172 # define mbsinit rpl_mbsinit
174 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
175 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
178 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
180 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
182 _GL_CXXALIASWARN (mbsinit);
183 #elif defined GNULIB_POSIXCHECK
185 # if HAVE_RAW_DECL_MBSINIT
186 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
187 "use gnulib module mbsinit for portability");
192 /* Convert a multibyte character to a wide character. */
194 # if @REPLACE_MBRTOWC@
195 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
197 # define mbrtowc rpl_mbrtowc
199 _GL_FUNCDECL_RPL (mbrtowc, size_t,
200 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
201 _GL_CXXALIAS_RPL (mbrtowc, size_t,
202 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
205 _GL_FUNCDECL_SYS (mbrtowc, size_t,
206 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
208 _GL_CXXALIAS_SYS (mbrtowc, size_t,
209 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
211 _GL_CXXALIASWARN (mbrtowc);
212 #elif defined GNULIB_POSIXCHECK
214 # if HAVE_RAW_DECL_MBRTOWC
215 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
216 "use gnulib module mbrtowc for portability");
221 /* Recognize a multibyte character. */
223 # if @REPLACE_MBRLEN@
224 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
226 # define mbrlen rpl_mbrlen
228 _GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
229 _GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
232 _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
234 _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
236 _GL_CXXALIASWARN (mbrlen);
237 #elif defined GNULIB_POSIXCHECK
239 # if HAVE_RAW_DECL_MBRLEN
240 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
241 "use gnulib module mbrlen for portability");
246 /* Convert a string to a wide string. */
247 #if @GNULIB_MBSRTOWCS@
248 # if @REPLACE_MBSRTOWCS@
249 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
251 # define mbsrtowcs rpl_mbsrtowcs
253 _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
254 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
255 _GL_ARG_NONNULL ((2)));
256 _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
257 (wchar_t *dest, const char **srcp, size_t len,
260 # if !@HAVE_MBSRTOWCS@
261 _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
262 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
263 _GL_ARG_NONNULL ((2)));
265 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
266 (wchar_t *dest, const char **srcp, size_t len,
269 _GL_CXXALIASWARN (mbsrtowcs);
270 #elif defined GNULIB_POSIXCHECK
272 # if HAVE_RAW_DECL_MBSRTOWCS
273 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
274 "use gnulib module mbsrtowcs for portability");
279 /* Convert a string to a wide string. */
280 #if @GNULIB_MBSNRTOWCS@
281 # if @REPLACE_MBSNRTOWCS@
282 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
284 # define mbsnrtowcs rpl_mbsnrtowcs
286 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
287 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
289 _GL_ARG_NONNULL ((2)));
290 _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
291 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
294 # if !@HAVE_MBSNRTOWCS@
295 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
296 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
298 _GL_ARG_NONNULL ((2)));
300 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
301 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
304 _GL_CXXALIASWARN (mbsnrtowcs);
305 #elif defined GNULIB_POSIXCHECK
307 # if HAVE_RAW_DECL_MBSNRTOWCS
308 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
309 "use gnulib module mbsnrtowcs for portability");
314 /* Convert a wide character to a multibyte character. */
316 # if @REPLACE_WCRTOMB@
317 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
319 # define wcrtomb rpl_wcrtomb
321 _GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
322 _GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
325 _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
327 _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
329 _GL_CXXALIASWARN (wcrtomb);
330 #elif defined GNULIB_POSIXCHECK
332 # if HAVE_RAW_DECL_WCRTOMB
333 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
334 "use gnulib module wcrtomb for portability");
339 /* Convert a wide string to a string. */
340 #if @GNULIB_WCSRTOMBS@
341 # if @REPLACE_WCSRTOMBS@
342 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
344 # define wcsrtombs rpl_wcsrtombs
346 _GL_FUNCDECL_RPL (wcsrtombs, size_t,
347 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
348 _GL_ARG_NONNULL ((2)));
349 _GL_CXXALIAS_RPL (wcsrtombs, size_t,
350 (char *dest, const wchar_t **srcp, size_t len,
353 # if !@HAVE_WCSRTOMBS@
354 _GL_FUNCDECL_SYS (wcsrtombs, size_t,
355 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
356 _GL_ARG_NONNULL ((2)));
358 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
359 (char *dest, const wchar_t **srcp, size_t len,
362 _GL_CXXALIASWARN (wcsrtombs);
363 #elif defined GNULIB_POSIXCHECK
365 # if HAVE_RAW_DECL_WCSRTOMBS
366 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
367 "use gnulib module wcsrtombs for portability");
372 /* Convert a wide string to a string. */
373 #if @GNULIB_WCSNRTOMBS@
374 # if @REPLACE_WCSNRTOMBS@
375 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
377 # define wcsnrtombs rpl_wcsnrtombs
379 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
380 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
382 _GL_ARG_NONNULL ((2)));
383 _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
384 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
387 # if !@HAVE_WCSNRTOMBS@
388 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
389 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
391 _GL_ARG_NONNULL ((2)));
393 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
394 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
397 _GL_CXXALIASWARN (wcsnrtombs);
398 #elif defined GNULIB_POSIXCHECK
400 # if HAVE_RAW_DECL_WCSNRTOMBS
401 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
402 "use gnulib module wcsnrtombs for portability");
407 /* Return the number of screen columns needed for WC. */
409 # if @REPLACE_WCWIDTH@
410 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
412 # define wcwidth rpl_wcwidth
414 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t));
415 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
417 # if !@HAVE_DECL_WCWIDTH@
418 /* wcwidth exists but is not declared. */
419 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t));
421 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
423 _GL_CXXALIASWARN (wcwidth);
424 #elif defined GNULIB_POSIXCHECK
426 # if HAVE_RAW_DECL_WCWIDTH
427 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
428 "use gnulib module wcwidth for portability");
433 /* Search N wide characters of S for C. */
436 _GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n));
438 /* On some systems, this function is defined as an overloaded function:
440 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
441 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
443 _GL_CXXALIAS_SYS_CAST2 (wmemchr,
444 wchar_t *, (const wchar_t *, wchar_t, size_t),
445 const wchar_t *, (const wchar_t *, wchar_t, size_t));
446 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
447 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
448 _GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
449 _GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
450 (const wchar_t *s, wchar_t c, size_t n));
452 _GL_CXXALIASWARN (wmemchr);
454 #elif defined GNULIB_POSIXCHECK
456 # if HAVE_RAW_DECL_WMEMCHR
457 _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
458 "use gnulib module wmemchr for portability");
463 /* Compare N wide characters of S1 and S2. */
466 _GL_FUNCDECL_SYS (wmemcmp, int,
467 (const wchar_t *s1, const wchar_t *s2, size_t n));
469 _GL_CXXALIAS_SYS (wmemcmp, int,
470 (const wchar_t *s1, const wchar_t *s2, size_t n));
471 _GL_CXXALIASWARN (wmemcmp);
472 #elif defined GNULIB_POSIXCHECK
474 # if HAVE_RAW_DECL_WMEMCMP
475 _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
476 "use gnulib module wmemcmp for portability");
481 /* Copy N wide characters of SRC to DEST. */
484 _GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
485 (wchar_t *dest, const wchar_t *src, size_t n));
487 _GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
488 (wchar_t *dest, const wchar_t *src, size_t n));
489 _GL_CXXALIASWARN (wmemcpy);
490 #elif defined GNULIB_POSIXCHECK
492 # if HAVE_RAW_DECL_WMEMCPY
493 _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
494 "use gnulib module wmemcpy for portability");
499 /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
500 overlapping memory areas. */
501 #if @GNULIB_WMEMMOVE@
502 # if !@HAVE_WMEMMOVE@
503 _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
504 (wchar_t *dest, const wchar_t *src, size_t n));
506 _GL_CXXALIAS_SYS (wmemmove, wchar_t *,
507 (wchar_t *dest, const wchar_t *src, size_t n));
508 _GL_CXXALIASWARN (wmemmove);
509 #elif defined GNULIB_POSIXCHECK
511 # if HAVE_RAW_DECL_WMEMMOVE
512 _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
513 "use gnulib module wmemmove for portability");
518 /* Set N wide characters of S to C. */
521 _GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
523 _GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
524 _GL_CXXALIASWARN (wmemset);
525 #elif defined GNULIB_POSIXCHECK
527 # if HAVE_RAW_DECL_WMEMSET
528 _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
529 "use gnulib module wmemset for portability");
534 /* Return the number of wide characters in S. */
537 _GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s));
539 _GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
540 _GL_CXXALIASWARN (wcslen);
541 #elif defined GNULIB_POSIXCHECK
543 # if HAVE_RAW_DECL_WCSLEN
544 _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
545 "use gnulib module wcslen for portability");
550 /* Return the number of wide characters in S, but at most MAXLEN. */
553 _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
555 _GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
556 _GL_CXXALIASWARN (wcsnlen);
557 #elif defined GNULIB_POSIXCHECK
559 # if HAVE_RAW_DECL_WCSNLEN
560 _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
561 "use gnulib module wcsnlen for portability");
566 /* Copy SRC to DEST. */
569 _GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
571 _GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
572 _GL_CXXALIASWARN (wcscpy);
573 #elif defined GNULIB_POSIXCHECK
575 # if HAVE_RAW_DECL_WCSCPY
576 _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
577 "use gnulib module wcscpy for portability");
582 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
585 _GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
587 _GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
588 _GL_CXXALIASWARN (wcpcpy);
589 #elif defined GNULIB_POSIXCHECK
591 # if HAVE_RAW_DECL_WCPCPY
592 _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
593 "use gnulib module wcpcpy for portability");
598 /* Copy no more than N wide characters of SRC to DEST. */
601 _GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
602 (wchar_t *dest, const wchar_t *src, size_t n));
604 _GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
605 (wchar_t *dest, const wchar_t *src, size_t n));
606 _GL_CXXALIASWARN (wcsncpy);
607 #elif defined GNULIB_POSIXCHECK
609 # if HAVE_RAW_DECL_WCSNCPY
610 _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
611 "use gnulib module wcsncpy for portability");
616 /* Copy no more than N characters of SRC to DEST, returning the address of
617 the last character written into DEST. */
620 _GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
621 (wchar_t *dest, const wchar_t *src, size_t n));
623 _GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
624 (wchar_t *dest, const wchar_t *src, size_t n));
625 _GL_CXXALIASWARN (wcpncpy);
626 #elif defined GNULIB_POSIXCHECK
628 # if HAVE_RAW_DECL_WCPNCPY
629 _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
630 "use gnulib module wcpncpy for portability");
635 /* Append SRC onto DEST. */
638 _GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
640 _GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
641 _GL_CXXALIASWARN (wcscat);
642 #elif defined GNULIB_POSIXCHECK
644 # if HAVE_RAW_DECL_WCSCAT
645 _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
646 "use gnulib module wcscat for portability");
651 /* Append no more than N wide characters of SRC onto DEST. */
654 _GL_FUNCDECL_SYS (wcsncat, wchar_t *,
655 (wchar_t *dest, const wchar_t *src, size_t n));
657 _GL_CXXALIAS_SYS (wcsncat, wchar_t *,
658 (wchar_t *dest, const wchar_t *src, size_t n));
659 _GL_CXXALIASWARN (wcsncat);
660 #elif defined GNULIB_POSIXCHECK
662 # if HAVE_RAW_DECL_WCSNCAT
663 _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
664 "use gnulib module wcsncat for portability");
669 /* Compare S1 and S2. */
672 _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
674 _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
675 _GL_CXXALIASWARN (wcscmp);
676 #elif defined GNULIB_POSIXCHECK
678 # if HAVE_RAW_DECL_WCSCMP
679 _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
680 "use gnulib module wcscmp for portability");
685 /* Compare no more than N wide characters of S1 and S2. */
688 _GL_FUNCDECL_SYS (wcsncmp, int,
689 (const wchar_t *s1, const wchar_t *s2, size_t n));
691 _GL_CXXALIAS_SYS (wcsncmp, int,
692 (const wchar_t *s1, const wchar_t *s2, size_t n));
693 _GL_CXXALIASWARN (wcsncmp);
694 #elif defined GNULIB_POSIXCHECK
696 # if HAVE_RAW_DECL_WCSNCMP
697 _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
698 "use gnulib module wcsncmp for portability");
703 /* Compare S1 and S2, ignoring case. */
704 #if @GNULIB_WCSCASECMP@
705 # if !@HAVE_WCSCASECMP@
706 _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
708 _GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
709 _GL_CXXALIASWARN (wcscasecmp);
710 #elif defined GNULIB_POSIXCHECK
712 # if HAVE_RAW_DECL_WCSCASECMP
713 _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
714 "use gnulib module wcscasecmp for portability");
719 /* Compare no more than N chars of S1 and S2, ignoring case. */
720 #if @GNULIB_WCSNCASECMP@
721 # if !@HAVE_WCSNCASECMP@
722 _GL_FUNCDECL_SYS (wcsncasecmp, int,
723 (const wchar_t *s1, const wchar_t *s2, size_t n));
725 _GL_CXXALIAS_SYS (wcsncasecmp, int,
726 (const wchar_t *s1, const wchar_t *s2, size_t n));
727 _GL_CXXALIASWARN (wcsncasecmp);
728 #elif defined GNULIB_POSIXCHECK
730 # if HAVE_RAW_DECL_WCSNCASECMP
731 _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
732 "use gnulib module wcsncasecmp for portability");
737 /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
738 category of the current locale. */
741 _GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
743 _GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
744 _GL_CXXALIASWARN (wcscoll);
745 #elif defined GNULIB_POSIXCHECK
747 # if HAVE_RAW_DECL_WCSCOLL
748 _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
749 "use gnulib module wcscoll for portability");
754 /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
755 to two transformed strings the result is the as applying 'wcscoll' to the
759 _GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
761 _GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
762 _GL_CXXALIASWARN (wcsxfrm);
763 #elif defined GNULIB_POSIXCHECK
765 # if HAVE_RAW_DECL_WCSXFRM
766 _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
767 "use gnulib module wcsxfrm for portability");
772 /* Duplicate S, returning an identical malloc'd string. */
775 _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s));
777 _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
778 _GL_CXXALIASWARN (wcsdup);
779 #elif defined GNULIB_POSIXCHECK
781 # if HAVE_RAW_DECL_WCSDUP
782 _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
783 "use gnulib module wcsdup for portability");
788 /* Find the first occurrence of WC in WCS. */
791 _GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
793 /* On some systems, this function is defined as an overloaded function:
795 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
796 wchar_t * std::wcschr (wchar_t *, wchar_t);
798 _GL_CXXALIAS_SYS_CAST2 (wcschr,
799 wchar_t *, (const wchar_t *, wchar_t),
800 const wchar_t *, (const wchar_t *, wchar_t));
801 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
802 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
803 _GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
804 _GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
806 _GL_CXXALIASWARN (wcschr);
808 #elif defined GNULIB_POSIXCHECK
810 # if HAVE_RAW_DECL_WCSCHR
811 _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
812 "use gnulib module wcschr for portability");
817 /* Find the last occurrence of WC in WCS. */
820 _GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
822 /* On some systems, this function is defined as an overloaded function:
824 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
825 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
827 _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
828 wchar_t *, (const wchar_t *, wchar_t),
829 const wchar_t *, (const wchar_t *, wchar_t));
830 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
831 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
832 _GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
833 _GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
835 _GL_CXXALIASWARN (wcsrchr);
837 #elif defined GNULIB_POSIXCHECK
839 # if HAVE_RAW_DECL_WCSRCHR
840 _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
841 "use gnulib module wcsrchr for portability");
846 /* Return the length of the initial segmet of WCS which consists entirely
847 of wide characters not in REJECT. */
850 _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
852 _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
853 _GL_CXXALIASWARN (wcscspn);
854 #elif defined GNULIB_POSIXCHECK
856 # if HAVE_RAW_DECL_WCSCSPN
857 _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
858 "use gnulib module wcscspn for portability");
863 /* Return the length of the initial segmet of WCS which consists entirely
864 of wide characters in ACCEPT. */
867 _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
869 _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
870 _GL_CXXALIASWARN (wcsspn);
871 #elif defined GNULIB_POSIXCHECK
873 # if HAVE_RAW_DECL_WCSSPN
874 _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
875 "use gnulib module wcsspn for portability");
880 /* Find the first occurrence in WCS of any character in ACCEPT. */
883 _GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
884 (const wchar_t *wcs, const wchar_t *accept));
886 /* On some systems, this function is defined as an overloaded function:
888 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
889 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
891 _GL_CXXALIAS_SYS_CAST2 (wcspbrk,
892 wchar_t *, (const wchar_t *, const wchar_t *),
893 const wchar_t *, (const wchar_t *, const wchar_t *));
894 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
895 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
896 _GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
897 (wchar_t *wcs, const wchar_t *accept));
898 _GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
899 (const wchar_t *wcs, const wchar_t *accept));
901 _GL_CXXALIASWARN (wcspbrk);
903 #elif defined GNULIB_POSIXCHECK
905 # if HAVE_RAW_DECL_WCSPBRK
906 _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
907 "use gnulib module wcspbrk for portability");
912 /* Find the first occurrence of NEEDLE in HAYSTACK. */
915 _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
916 (const wchar_t *haystack, const wchar_t *needle));
918 /* On some systems, this function is defined as an overloaded function:
920 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
921 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
923 _GL_CXXALIAS_SYS_CAST2 (wcsstr,
924 wchar_t *, (const wchar_t *, const wchar_t *),
925 const wchar_t *, (const wchar_t *, const wchar_t *));
926 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
927 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
928 _GL_CXXALIASWARN1 (wcsstr, wchar_t *,
929 (wchar_t *haystack, const wchar_t *needle));
930 _GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
931 (const wchar_t *haystack, const wchar_t *needle));
933 _GL_CXXALIASWARN (wcsstr);
935 #elif defined GNULIB_POSIXCHECK
937 # if HAVE_RAW_DECL_WCSSTR
938 _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
939 "use gnulib module wcsstr for portability");
944 /* Divide WCS into tokens separated by characters in DELIM. */
947 _GL_FUNCDECL_SYS (wcstok, wchar_t *,
948 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
950 _GL_CXXALIAS_SYS (wcstok, wchar_t *,
951 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
952 _GL_CXXALIASWARN (wcstok);
953 #elif defined GNULIB_POSIXCHECK
955 # if HAVE_RAW_DECL_WCSTOK
956 _GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
957 "use gnulib module wcstok for portability");
962 /* Determine number of column positions required for first N wide
963 characters (or fewer if S ends before this) in S. */
964 #if @GNULIB_WCSWIDTH@
965 # if @REPLACE_WCSWIDTH@
966 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
968 # define wcswidth rpl_wcswidth
970 _GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n));
971 _GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
973 # if !@HAVE_WCSWIDTH@
974 _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n));
976 _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
978 _GL_CXXALIASWARN (wcswidth);
979 #elif defined GNULIB_POSIXCHECK
981 # if HAVE_RAW_DECL_WCSWIDTH
982 _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
983 "use gnulib module wcswidth for portability");
988 #endif /* _GL_WCHAR_H */
989 #endif /* _GL_WCHAR_H */