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
102 # define WEOF ((wint_t) -1)
107 /* Override mbstate_t if it is too small.
108 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
109 implementing mbrtowc for encodings like UTF-8. */
110 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
111 # if !GNULIB_defined_mbstate_t
112 typedef int rpl_mbstate_t;
114 # define mbstate_t rpl_mbstate_t
115 # define GNULIB_defined_mbstate_t 1
120 /* Convert a single-byte character to a wide character. */
123 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
125 # define btowc rpl_btowc
127 _GL_FUNCDECL_RPL (btowc, wint_t, (int c));
128 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
131 _GL_FUNCDECL_SYS (btowc, wint_t, (int c));
133 _GL_CXXALIAS_SYS (btowc, wint_t, (int c));
135 _GL_CXXALIASWARN (btowc);
136 #elif defined GNULIB_POSIXCHECK
138 # if HAVE_RAW_DECL_BTOWC
139 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
140 "use gnulib module btowc for portability");
145 /* Convert a wide character to a single-byte character. */
148 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
150 # define wctob rpl_wctob
152 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc));
153 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
155 # if !defined wctob && !@HAVE_DECL_WCTOB@
156 /* wctob is provided by gnulib, or wctob exists but is not declared. */
157 _GL_FUNCDECL_SYS (wctob, int, (wint_t wc));
159 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
161 _GL_CXXALIASWARN (wctob);
162 #elif defined GNULIB_POSIXCHECK
164 # if HAVE_RAW_DECL_WCTOB
165 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
166 "use gnulib module wctob for portability");
171 /* Test whether *PS is in the initial state. */
173 # if @REPLACE_MBSINIT@
174 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
176 # define mbsinit rpl_mbsinit
178 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
179 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
182 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
184 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
186 _GL_CXXALIASWARN (mbsinit);
187 #elif defined GNULIB_POSIXCHECK
189 # if HAVE_RAW_DECL_MBSINIT
190 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
191 "use gnulib module mbsinit for portability");
196 /* Convert a multibyte character to a wide character. */
198 # if @REPLACE_MBRTOWC@
199 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
201 # define mbrtowc rpl_mbrtowc
203 _GL_FUNCDECL_RPL (mbrtowc, size_t,
204 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
205 _GL_CXXALIAS_RPL (mbrtowc, size_t,
206 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
209 _GL_FUNCDECL_SYS (mbrtowc, size_t,
210 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
212 _GL_CXXALIAS_SYS (mbrtowc, size_t,
213 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
215 _GL_CXXALIASWARN (mbrtowc);
216 #elif defined GNULIB_POSIXCHECK
218 # if HAVE_RAW_DECL_MBRTOWC
219 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
220 "use gnulib module mbrtowc for portability");
225 /* Recognize a multibyte character. */
227 # if @REPLACE_MBRLEN@
228 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
230 # define mbrlen rpl_mbrlen
232 _GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
233 _GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
236 _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
238 _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
240 _GL_CXXALIASWARN (mbrlen);
241 #elif defined GNULIB_POSIXCHECK
243 # if HAVE_RAW_DECL_MBRLEN
244 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
245 "use gnulib module mbrlen for portability");
250 /* Convert a string to a wide string. */
251 #if @GNULIB_MBSRTOWCS@
252 # if @REPLACE_MBSRTOWCS@
253 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
255 # define mbsrtowcs rpl_mbsrtowcs
257 _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
258 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
259 _GL_ARG_NONNULL ((2)));
260 _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
261 (wchar_t *dest, const char **srcp, size_t len,
264 # if !@HAVE_MBSRTOWCS@
265 _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
266 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
267 _GL_ARG_NONNULL ((2)));
269 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
270 (wchar_t *dest, const char **srcp, size_t len,
273 _GL_CXXALIASWARN (mbsrtowcs);
274 #elif defined GNULIB_POSIXCHECK
276 # if HAVE_RAW_DECL_MBSRTOWCS
277 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
278 "use gnulib module mbsrtowcs for portability");
283 /* Convert a string to a wide string. */
284 #if @GNULIB_MBSNRTOWCS@
285 # if @REPLACE_MBSNRTOWCS@
286 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
288 # define mbsnrtowcs rpl_mbsnrtowcs
290 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
291 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
293 _GL_ARG_NONNULL ((2)));
294 _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
295 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
298 # if !@HAVE_MBSNRTOWCS@
299 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
300 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
302 _GL_ARG_NONNULL ((2)));
304 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
305 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
308 _GL_CXXALIASWARN (mbsnrtowcs);
309 #elif defined GNULIB_POSIXCHECK
311 # if HAVE_RAW_DECL_MBSNRTOWCS
312 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
313 "use gnulib module mbsnrtowcs for portability");
318 /* Convert a wide character to a multibyte character. */
320 # if @REPLACE_WCRTOMB@
321 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
323 # define wcrtomb rpl_wcrtomb
325 _GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
326 _GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
329 _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
331 _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
333 _GL_CXXALIASWARN (wcrtomb);
334 #elif defined GNULIB_POSIXCHECK
336 # if HAVE_RAW_DECL_WCRTOMB
337 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
338 "use gnulib module wcrtomb for portability");
343 /* Convert a wide string to a string. */
344 #if @GNULIB_WCSRTOMBS@
345 # if @REPLACE_WCSRTOMBS@
346 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
348 # define wcsrtombs rpl_wcsrtombs
350 _GL_FUNCDECL_RPL (wcsrtombs, size_t,
351 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
352 _GL_ARG_NONNULL ((2)));
353 _GL_CXXALIAS_RPL (wcsrtombs, size_t,
354 (char *dest, const wchar_t **srcp, size_t len,
357 # if !@HAVE_WCSRTOMBS@
358 _GL_FUNCDECL_SYS (wcsrtombs, size_t,
359 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
360 _GL_ARG_NONNULL ((2)));
362 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
363 (char *dest, const wchar_t **srcp, size_t len,
366 _GL_CXXALIASWARN (wcsrtombs);
367 #elif defined GNULIB_POSIXCHECK
369 # if HAVE_RAW_DECL_WCSRTOMBS
370 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
371 "use gnulib module wcsrtombs for portability");
376 /* Convert a wide string to a string. */
377 #if @GNULIB_WCSNRTOMBS@
378 # if @REPLACE_WCSNRTOMBS@
379 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
381 # define wcsnrtombs rpl_wcsnrtombs
383 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
384 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
386 _GL_ARG_NONNULL ((2)));
387 _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
388 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
391 # if !@HAVE_WCSNRTOMBS@
392 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
393 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
395 _GL_ARG_NONNULL ((2)));
397 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
398 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
401 _GL_CXXALIASWARN (wcsnrtombs);
402 #elif defined GNULIB_POSIXCHECK
404 # if HAVE_RAW_DECL_WCSNRTOMBS
405 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
406 "use gnulib module wcsnrtombs for portability");
411 /* Return the number of screen columns needed for WC. */
413 # if @REPLACE_WCWIDTH@
414 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
416 # define wcwidth rpl_wcwidth
418 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t));
419 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
421 # if !@HAVE_DECL_WCWIDTH@
422 /* wcwidth exists but is not declared. */
423 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t));
425 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
427 _GL_CXXALIASWARN (wcwidth);
428 #elif defined GNULIB_POSIXCHECK
430 # if HAVE_RAW_DECL_WCWIDTH
431 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
432 "use gnulib module wcwidth for portability");
437 /* Search N wide characters of S for C. */
440 _GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n));
442 /* On some systems, this function is defined as an overloaded function:
444 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
445 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
447 _GL_CXXALIAS_SYS_CAST2 (wmemchr,
448 wchar_t *, (const wchar_t *, wchar_t, size_t),
449 const wchar_t *, (const wchar_t *, wchar_t, size_t));
450 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
451 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
452 _GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
453 _GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
454 (const wchar_t *s, wchar_t c, size_t n));
456 _GL_CXXALIASWARN (wmemchr);
458 #elif defined GNULIB_POSIXCHECK
460 # if HAVE_RAW_DECL_WMEMCHR
461 _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
462 "use gnulib module wmemchr for portability");
467 /* Compare N wide characters of S1 and S2. */
470 _GL_FUNCDECL_SYS (wmemcmp, int,
471 (const wchar_t *s1, const wchar_t *s2, size_t n));
473 _GL_CXXALIAS_SYS (wmemcmp, int,
474 (const wchar_t *s1, const wchar_t *s2, size_t n));
475 _GL_CXXALIASWARN (wmemcmp);
476 #elif defined GNULIB_POSIXCHECK
478 # if HAVE_RAW_DECL_WMEMCMP
479 _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
480 "use gnulib module wmemcmp for portability");
485 /* Copy N wide characters of SRC to DEST. */
488 _GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
489 (wchar_t *dest, const wchar_t *src, size_t n));
491 _GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
492 (wchar_t *dest, const wchar_t *src, size_t n));
493 _GL_CXXALIASWARN (wmemcpy);
494 #elif defined GNULIB_POSIXCHECK
496 # if HAVE_RAW_DECL_WMEMCPY
497 _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
498 "use gnulib module wmemcpy for portability");
503 /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
504 overlapping memory areas. */
505 #if @GNULIB_WMEMMOVE@
506 # if !@HAVE_WMEMMOVE@
507 _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
508 (wchar_t *dest, const wchar_t *src, size_t n));
510 _GL_CXXALIAS_SYS (wmemmove, wchar_t *,
511 (wchar_t *dest, const wchar_t *src, size_t n));
512 _GL_CXXALIASWARN (wmemmove);
513 #elif defined GNULIB_POSIXCHECK
515 # if HAVE_RAW_DECL_WMEMMOVE
516 _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
517 "use gnulib module wmemmove for portability");
522 /* Set N wide characters of S to C. */
525 _GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
527 _GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
528 _GL_CXXALIASWARN (wmemset);
529 #elif defined GNULIB_POSIXCHECK
531 # if HAVE_RAW_DECL_WMEMSET
532 _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
533 "use gnulib module wmemset for portability");
538 /* Return the number of wide characters in S. */
541 _GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s));
543 _GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
544 _GL_CXXALIASWARN (wcslen);
545 #elif defined GNULIB_POSIXCHECK
547 # if HAVE_RAW_DECL_WCSLEN
548 _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
549 "use gnulib module wcslen for portability");
554 /* Return the number of wide characters in S, but at most MAXLEN. */
557 _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
559 _GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
560 _GL_CXXALIASWARN (wcsnlen);
561 #elif defined GNULIB_POSIXCHECK
563 # if HAVE_RAW_DECL_WCSNLEN
564 _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
565 "use gnulib module wcsnlen for portability");
570 /* Copy SRC to DEST. */
573 _GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
575 _GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
576 _GL_CXXALIASWARN (wcscpy);
577 #elif defined GNULIB_POSIXCHECK
579 # if HAVE_RAW_DECL_WCSCPY
580 _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
581 "use gnulib module wcscpy for portability");
586 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
589 _GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
591 _GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
592 _GL_CXXALIASWARN (wcpcpy);
593 #elif defined GNULIB_POSIXCHECK
595 # if HAVE_RAW_DECL_WCPCPY
596 _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
597 "use gnulib module wcpcpy for portability");
602 /* Copy no more than N wide characters of SRC to DEST. */
605 _GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
606 (wchar_t *dest, const wchar_t *src, size_t n));
608 _GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
609 (wchar_t *dest, const wchar_t *src, size_t n));
610 _GL_CXXALIASWARN (wcsncpy);
611 #elif defined GNULIB_POSIXCHECK
613 # if HAVE_RAW_DECL_WCSNCPY
614 _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
615 "use gnulib module wcsncpy for portability");
620 /* Copy no more than N characters of SRC to DEST, returning the address of
621 the last character written into DEST. */
624 _GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
625 (wchar_t *dest, const wchar_t *src, size_t n));
627 _GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
628 (wchar_t *dest, const wchar_t *src, size_t n));
629 _GL_CXXALIASWARN (wcpncpy);
630 #elif defined GNULIB_POSIXCHECK
632 # if HAVE_RAW_DECL_WCPNCPY
633 _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
634 "use gnulib module wcpncpy for portability");
639 /* Append SRC onto DEST. */
642 _GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
644 _GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
645 _GL_CXXALIASWARN (wcscat);
646 #elif defined GNULIB_POSIXCHECK
648 # if HAVE_RAW_DECL_WCSCAT
649 _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
650 "use gnulib module wcscat for portability");
655 /* Append no more than N wide characters of SRC onto DEST. */
658 _GL_FUNCDECL_SYS (wcsncat, wchar_t *,
659 (wchar_t *dest, const wchar_t *src, size_t n));
661 _GL_CXXALIAS_SYS (wcsncat, wchar_t *,
662 (wchar_t *dest, const wchar_t *src, size_t n));
663 _GL_CXXALIASWARN (wcsncat);
664 #elif defined GNULIB_POSIXCHECK
666 # if HAVE_RAW_DECL_WCSNCAT
667 _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
668 "use gnulib module wcsncat for portability");
673 /* Compare S1 and S2. */
676 _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
678 _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
679 _GL_CXXALIASWARN (wcscmp);
680 #elif defined GNULIB_POSIXCHECK
682 # if HAVE_RAW_DECL_WCSCMP
683 _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
684 "use gnulib module wcscmp for portability");
689 /* Compare no more than N wide characters of S1 and S2. */
692 _GL_FUNCDECL_SYS (wcsncmp, int,
693 (const wchar_t *s1, const wchar_t *s2, size_t n));
695 _GL_CXXALIAS_SYS (wcsncmp, int,
696 (const wchar_t *s1, const wchar_t *s2, size_t n));
697 _GL_CXXALIASWARN (wcsncmp);
698 #elif defined GNULIB_POSIXCHECK
700 # if HAVE_RAW_DECL_WCSNCMP
701 _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
702 "use gnulib module wcsncmp for portability");
707 /* Compare S1 and S2, ignoring case. */
708 #if @GNULIB_WCSCASECMP@
709 # if !@HAVE_WCSCASECMP@
710 _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
712 _GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
713 _GL_CXXALIASWARN (wcscasecmp);
714 #elif defined GNULIB_POSIXCHECK
716 # if HAVE_RAW_DECL_WCSCASECMP
717 _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
718 "use gnulib module wcscasecmp for portability");
723 /* Compare no more than N chars of S1 and S2, ignoring case. */
724 #if @GNULIB_WCSNCASECMP@
725 # if !@HAVE_WCSNCASECMP@
726 _GL_FUNCDECL_SYS (wcsncasecmp, int,
727 (const wchar_t *s1, const wchar_t *s2, size_t n));
729 _GL_CXXALIAS_SYS (wcsncasecmp, int,
730 (const wchar_t *s1, const wchar_t *s2, size_t n));
731 _GL_CXXALIASWARN (wcsncasecmp);
732 #elif defined GNULIB_POSIXCHECK
734 # if HAVE_RAW_DECL_WCSNCASECMP
735 _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
736 "use gnulib module wcsncasecmp for portability");
741 /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
742 category of the current locale. */
745 _GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
747 _GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
748 _GL_CXXALIASWARN (wcscoll);
749 #elif defined GNULIB_POSIXCHECK
751 # if HAVE_RAW_DECL_WCSCOLL
752 _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
753 "use gnulib module wcscoll for portability");
758 /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
759 to two transformed strings the result is the as applying 'wcscoll' to the
763 _GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
765 _GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
766 _GL_CXXALIASWARN (wcsxfrm);
767 #elif defined GNULIB_POSIXCHECK
769 # if HAVE_RAW_DECL_WCSXFRM
770 _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
771 "use gnulib module wcsxfrm for portability");
776 /* Duplicate S, returning an identical malloc'd string. */
779 _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s));
781 _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
782 _GL_CXXALIASWARN (wcsdup);
783 #elif defined GNULIB_POSIXCHECK
785 # if HAVE_RAW_DECL_WCSDUP
786 _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
787 "use gnulib module wcsdup for portability");
792 /* Find the first occurrence of WC in WCS. */
795 _GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
797 /* On some systems, this function is defined as an overloaded function:
799 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
800 wchar_t * std::wcschr (wchar_t *, wchar_t);
802 _GL_CXXALIAS_SYS_CAST2 (wcschr,
803 wchar_t *, (const wchar_t *, wchar_t),
804 const wchar_t *, (const wchar_t *, wchar_t));
805 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
806 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
807 _GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
808 _GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
810 _GL_CXXALIASWARN (wcschr);
812 #elif defined GNULIB_POSIXCHECK
814 # if HAVE_RAW_DECL_WCSCHR
815 _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
816 "use gnulib module wcschr for portability");
821 /* Find the last occurrence of WC in WCS. */
824 _GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
826 /* On some systems, this function is defined as an overloaded function:
828 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
829 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
831 _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
832 wchar_t *, (const wchar_t *, wchar_t),
833 const wchar_t *, (const wchar_t *, wchar_t));
834 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
835 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
836 _GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
837 _GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
839 _GL_CXXALIASWARN (wcsrchr);
841 #elif defined GNULIB_POSIXCHECK
843 # if HAVE_RAW_DECL_WCSRCHR
844 _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
845 "use gnulib module wcsrchr for portability");
850 /* Return the length of the initial segmet of WCS which consists entirely
851 of wide characters not in REJECT. */
854 _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
856 _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
857 _GL_CXXALIASWARN (wcscspn);
858 #elif defined GNULIB_POSIXCHECK
860 # if HAVE_RAW_DECL_WCSCSPN
861 _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
862 "use gnulib module wcscspn for portability");
867 /* Return the length of the initial segmet of WCS which consists entirely
868 of wide characters in ACCEPT. */
871 _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
873 _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
874 _GL_CXXALIASWARN (wcsspn);
875 #elif defined GNULIB_POSIXCHECK
877 # if HAVE_RAW_DECL_WCSSPN
878 _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
879 "use gnulib module wcsspn for portability");
884 /* Find the first occurrence in WCS of any character in ACCEPT. */
887 _GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
888 (const wchar_t *wcs, const wchar_t *accept));
890 /* On some systems, this function is defined as an overloaded function:
892 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
893 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
895 _GL_CXXALIAS_SYS_CAST2 (wcspbrk,
896 wchar_t *, (const wchar_t *, const wchar_t *),
897 const wchar_t *, (const wchar_t *, const wchar_t *));
898 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
899 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
900 _GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
901 (wchar_t *wcs, const wchar_t *accept));
902 _GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
903 (const wchar_t *wcs, const wchar_t *accept));
905 _GL_CXXALIASWARN (wcspbrk);
907 #elif defined GNULIB_POSIXCHECK
909 # if HAVE_RAW_DECL_WCSPBRK
910 _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
911 "use gnulib module wcspbrk for portability");
916 /* Find the first occurrence of NEEDLE in HAYSTACK. */
919 _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
920 (const wchar_t *haystack, const wchar_t *needle));
922 /* On some systems, this function is defined as an overloaded function:
924 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
925 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
927 _GL_CXXALIAS_SYS_CAST2 (wcsstr,
928 wchar_t *, (const wchar_t *, const wchar_t *),
929 const wchar_t *, (const wchar_t *, const wchar_t *));
930 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
931 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
932 _GL_CXXALIASWARN1 (wcsstr, wchar_t *,
933 (wchar_t *haystack, const wchar_t *needle));
934 _GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
935 (const wchar_t *haystack, const wchar_t *needle));
937 _GL_CXXALIASWARN (wcsstr);
939 #elif defined GNULIB_POSIXCHECK
941 # if HAVE_RAW_DECL_WCSSTR
942 _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
943 "use gnulib module wcsstr for portability");
948 /* Divide WCS into tokens separated by characters in DELIM. */
951 _GL_FUNCDECL_SYS (wcstok, wchar_t *,
952 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
954 _GL_CXXALIAS_SYS (wcstok, wchar_t *,
955 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
956 _GL_CXXALIASWARN (wcstok);
957 #elif defined GNULIB_POSIXCHECK
959 # if HAVE_RAW_DECL_WCSTOK
960 _GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
961 "use gnulib module wcstok for portability");
966 /* Determine number of column positions required for first N wide
967 characters (or fewer if S ends before this) in S. */
968 #if @GNULIB_WCSWIDTH@
969 # if @REPLACE_WCSWIDTH@
970 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
972 # define wcswidth rpl_wcswidth
974 _GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n));
975 _GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
977 # if !@HAVE_WCSWIDTH@
978 _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n));
980 _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
982 _GL_CXXALIASWARN (wcswidth);
983 #elif defined GNULIB_POSIXCHECK
985 # if HAVE_RAW_DECL_WCSWIDTH
986 _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
987 "use gnulib module wcswidth for portability");
992 #endif /* _@GUARD_PREFIX@_WCHAR_H */
993 #endif /* _@GUARD_PREFIX@_WCHAR_H */