1 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
3 Copyright (C) 2007-2016 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__ && !defined __KLIBC__) \
36 && ((defined _INTTYPES_INCLUDED && !defined strtoimax) \
37 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
38 || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
39 || defined _GL_ALREADY_INCLUDING_WCHAR_H)
40 /* Special invocation convention:
41 - Inside glibc and uClibc header files, but not MinGW.
42 - On HP-UX 11.00 we have a sequence of nested includes
43 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
44 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
45 and once directly. In both situations 'wint_t' is not yet defined,
46 therefore we cannot provide the function overrides; instead include only
47 the system's <wchar.h>.
48 - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of
49 <wchar.h> is actually processed, and that doesn't include 'mbstate_t'.
50 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
51 the latter includes <wchar.h>. But here, we have no way to detect whether
52 <wctype.h> is completely included or is still being included. */
54 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
57 /* Normal invocation convention. */
59 #ifndef _@GUARD_PREFIX@_WCHAR_H
61 #define _GL_ALREADY_INCLUDING_WCHAR_H
64 # include <features.h> /* for __GLIBC__ */
67 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
69 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
70 included before <wchar.h>.
71 In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
73 But avoid namespace pollution on glibc systems. */
74 #if !(defined __GLIBC__ && !defined __UCLIBC__)
82 /* Include the original <wchar.h> if it exists.
83 Some builds of uClibc lack it. */
84 /* The include_next requires a split double-inclusion guard. */
86 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
89 #undef _GL_ALREADY_INCLUDING_WCHAR_H
91 #ifndef _@GUARD_PREFIX@_WCHAR_H
92 #define _@GUARD_PREFIX@_WCHAR_H
94 /* The __attribute__ feature is available in gcc versions 2.5 and later.
95 The attribute __pure__ was added in gcc 2.96. */
96 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
97 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
99 # define _GL_ATTRIBUTE_PURE /* empty */
102 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
104 /* The definition of _GL_ARG_NONNULL is copied here. */
106 /* The definition of _GL_WARN_ON_USE is copied here. */
109 /* Define wint_t and WEOF. (Also done in wctype.in.h.) */
110 #if !@HAVE_WINT_T@ && !defined wint_t
116 /* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>.
117 This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be
118 "unchanged by default argument promotions". Override it. */
119 # if defined _MSC_VER
120 # if !GNULIB_defined_wint_t
121 # include <crtdefs.h>
122 typedef unsigned int rpl_wint_t;
124 # define wint_t rpl_wint_t
125 # define GNULIB_defined_wint_t 1
129 # define WEOF ((wint_t) -1)
134 /* Override mbstate_t if it is too small.
135 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
136 implementing mbrtowc for encodings like UTF-8. */
137 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
138 # if !GNULIB_defined_mbstate_t
139 typedef int rpl_mbstate_t;
141 # define mbstate_t rpl_mbstate_t
142 # define GNULIB_defined_mbstate_t 1
147 /* Convert a single-byte character to a wide character. */
150 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
152 # define btowc rpl_btowc
154 _GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
155 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
158 _GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
160 _GL_CXXALIAS_SYS (btowc, wint_t, (int c));
162 _GL_CXXALIASWARN (btowc);
163 #elif defined GNULIB_POSIXCHECK
165 # if HAVE_RAW_DECL_BTOWC
166 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
167 "use gnulib module btowc for portability");
172 /* Convert a wide character to a single-byte character. */
175 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
177 # define wctob rpl_wctob
179 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
180 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
182 # if !defined wctob && !@HAVE_DECL_WCTOB@
183 /* wctob is provided by gnulib, or wctob exists but is not declared. */
184 _GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
186 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
188 _GL_CXXALIASWARN (wctob);
189 #elif defined GNULIB_POSIXCHECK
191 # if HAVE_RAW_DECL_WCTOB
192 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
193 "use gnulib module wctob for portability");
198 /* Test whether *PS is in the initial state. */
200 # if @REPLACE_MBSINIT@
201 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
203 # define mbsinit rpl_mbsinit
205 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
206 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
209 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
211 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
213 _GL_CXXALIASWARN (mbsinit);
214 #elif defined GNULIB_POSIXCHECK
216 # if HAVE_RAW_DECL_MBSINIT
217 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
218 "use gnulib module mbsinit for portability");
223 /* Convert a multibyte character to a wide character. */
225 # if @REPLACE_MBRTOWC@
226 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
228 # define mbrtowc rpl_mbrtowc
230 _GL_FUNCDECL_RPL (mbrtowc, size_t,
231 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
232 _GL_CXXALIAS_RPL (mbrtowc, size_t,
233 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
236 _GL_FUNCDECL_SYS (mbrtowc, size_t,
237 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
239 _GL_CXXALIAS_SYS (mbrtowc, size_t,
240 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
242 _GL_CXXALIASWARN (mbrtowc);
243 #elif defined GNULIB_POSIXCHECK
245 # if HAVE_RAW_DECL_MBRTOWC
246 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
247 "use gnulib module mbrtowc for portability");
252 /* Recognize a multibyte character. */
254 # if @REPLACE_MBRLEN@
255 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
257 # define mbrlen rpl_mbrlen
259 _GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
260 _GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
263 _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
265 _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
267 _GL_CXXALIASWARN (mbrlen);
268 #elif defined GNULIB_POSIXCHECK
270 # if HAVE_RAW_DECL_MBRLEN
271 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
272 "use gnulib module mbrlen for portability");
277 /* Convert a string to a wide string. */
278 #if @GNULIB_MBSRTOWCS@
279 # if @REPLACE_MBSRTOWCS@
280 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
282 # define mbsrtowcs rpl_mbsrtowcs
284 _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
285 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
286 _GL_ARG_NONNULL ((2)));
287 _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
288 (wchar_t *dest, const char **srcp, size_t len,
291 # if !@HAVE_MBSRTOWCS@
292 _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
293 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
294 _GL_ARG_NONNULL ((2)));
296 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
297 (wchar_t *dest, const char **srcp, size_t len,
300 _GL_CXXALIASWARN (mbsrtowcs);
301 #elif defined GNULIB_POSIXCHECK
303 # if HAVE_RAW_DECL_MBSRTOWCS
304 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
305 "use gnulib module mbsrtowcs for portability");
310 /* Convert a string to a wide string. */
311 #if @GNULIB_MBSNRTOWCS@
312 # if @REPLACE_MBSNRTOWCS@
313 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
315 # define mbsnrtowcs rpl_mbsnrtowcs
317 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
318 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
320 _GL_ARG_NONNULL ((2)));
321 _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
322 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
325 # if !@HAVE_MBSNRTOWCS@
326 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
327 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
329 _GL_ARG_NONNULL ((2)));
331 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
332 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
335 _GL_CXXALIASWARN (mbsnrtowcs);
336 #elif defined GNULIB_POSIXCHECK
338 # if HAVE_RAW_DECL_MBSNRTOWCS
339 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
340 "use gnulib module mbsnrtowcs for portability");
345 /* Convert a wide character to a multibyte character. */
347 # if @REPLACE_WCRTOMB@
348 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
350 # define wcrtomb rpl_wcrtomb
352 _GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
353 _GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
356 _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
358 _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
360 _GL_CXXALIASWARN (wcrtomb);
361 #elif defined GNULIB_POSIXCHECK
363 # if HAVE_RAW_DECL_WCRTOMB
364 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
365 "use gnulib module wcrtomb for portability");
370 /* Convert a wide string to a string. */
371 #if @GNULIB_WCSRTOMBS@
372 # if @REPLACE_WCSRTOMBS@
373 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
375 # define wcsrtombs rpl_wcsrtombs
377 _GL_FUNCDECL_RPL (wcsrtombs, size_t,
378 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
379 _GL_ARG_NONNULL ((2)));
380 _GL_CXXALIAS_RPL (wcsrtombs, size_t,
381 (char *dest, const wchar_t **srcp, size_t len,
384 # if !@HAVE_WCSRTOMBS@
385 _GL_FUNCDECL_SYS (wcsrtombs, size_t,
386 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
387 _GL_ARG_NONNULL ((2)));
389 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
390 (char *dest, const wchar_t **srcp, size_t len,
393 _GL_CXXALIASWARN (wcsrtombs);
394 #elif defined GNULIB_POSIXCHECK
396 # if HAVE_RAW_DECL_WCSRTOMBS
397 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
398 "use gnulib module wcsrtombs for portability");
403 /* Convert a wide string to a string. */
404 #if @GNULIB_WCSNRTOMBS@
405 # if @REPLACE_WCSNRTOMBS@
406 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
408 # define wcsnrtombs rpl_wcsnrtombs
410 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
411 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
413 _GL_ARG_NONNULL ((2)));
414 _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
415 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
418 # if !@HAVE_WCSNRTOMBS@
419 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
420 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
422 _GL_ARG_NONNULL ((2)));
424 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
425 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
428 _GL_CXXALIASWARN (wcsnrtombs);
429 #elif defined GNULIB_POSIXCHECK
431 # if HAVE_RAW_DECL_WCSNRTOMBS
432 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
433 "use gnulib module wcsnrtombs for portability");
438 /* Return the number of screen columns needed for WC. */
440 # if @REPLACE_WCWIDTH@
441 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
443 # define wcwidth rpl_wcwidth
445 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
446 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
448 # if !@HAVE_DECL_WCWIDTH@
449 /* wcwidth exists but is not declared. */
450 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
451 # elif defined __KLIBC__
452 /* On OS/2 kLIBC, wcwidth is a macro that expands to the name of a
453 static inline function. The implementation of wcwidth in wcwidth.c
454 causes a "conflicting types" error. */
457 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
459 _GL_CXXALIASWARN (wcwidth);
460 #elif defined GNULIB_POSIXCHECK
462 # if HAVE_RAW_DECL_WCWIDTH
463 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
464 "use gnulib module wcwidth for portability");
469 /* Search N wide characters of S for C. */
472 _GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n)
475 /* On some systems, this function is defined as an overloaded function:
477 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
478 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
480 _GL_CXXALIAS_SYS_CAST2 (wmemchr,
481 wchar_t *, (const wchar_t *, wchar_t, size_t),
482 const wchar_t *, (const wchar_t *, wchar_t, size_t));
483 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
484 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
485 _GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
486 _GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
487 (const wchar_t *s, wchar_t c, size_t n));
489 _GL_CXXALIASWARN (wmemchr);
491 #elif defined GNULIB_POSIXCHECK
493 # if HAVE_RAW_DECL_WMEMCHR
494 _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
495 "use gnulib module wmemchr for portability");
500 /* Compare N wide characters of S1 and S2. */
503 _GL_FUNCDECL_SYS (wmemcmp, int,
504 (const wchar_t *s1, const wchar_t *s2, size_t n)
507 _GL_CXXALIAS_SYS (wmemcmp, int,
508 (const wchar_t *s1, const wchar_t *s2, size_t n));
509 _GL_CXXALIASWARN (wmemcmp);
510 #elif defined GNULIB_POSIXCHECK
512 # if HAVE_RAW_DECL_WMEMCMP
513 _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
514 "use gnulib module wmemcmp for portability");
519 /* Copy N wide characters of SRC to DEST. */
522 _GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
523 (wchar_t *dest, const wchar_t *src, size_t n));
525 _GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
526 (wchar_t *dest, const wchar_t *src, size_t n));
527 _GL_CXXALIASWARN (wmemcpy);
528 #elif defined GNULIB_POSIXCHECK
530 # if HAVE_RAW_DECL_WMEMCPY
531 _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
532 "use gnulib module wmemcpy for portability");
537 /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
538 overlapping memory areas. */
539 #if @GNULIB_WMEMMOVE@
540 # if !@HAVE_WMEMMOVE@
541 _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
542 (wchar_t *dest, const wchar_t *src, size_t n));
544 _GL_CXXALIAS_SYS (wmemmove, wchar_t *,
545 (wchar_t *dest, const wchar_t *src, size_t n));
546 _GL_CXXALIASWARN (wmemmove);
547 #elif defined GNULIB_POSIXCHECK
549 # if HAVE_RAW_DECL_WMEMMOVE
550 _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
551 "use gnulib module wmemmove for portability");
556 /* Set N wide characters of S to C. */
559 _GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
561 _GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
562 _GL_CXXALIASWARN (wmemset);
563 #elif defined GNULIB_POSIXCHECK
565 # if HAVE_RAW_DECL_WMEMSET
566 _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
567 "use gnulib module wmemset for portability");
572 /* Return the number of wide characters in S. */
575 _GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE);
577 _GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
578 _GL_CXXALIASWARN (wcslen);
579 #elif defined GNULIB_POSIXCHECK
581 # if HAVE_RAW_DECL_WCSLEN
582 _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
583 "use gnulib module wcslen for portability");
588 /* Return the number of wide characters in S, but at most MAXLEN. */
591 _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)
594 _GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
595 _GL_CXXALIASWARN (wcsnlen);
596 #elif defined GNULIB_POSIXCHECK
598 # if HAVE_RAW_DECL_WCSNLEN
599 _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
600 "use gnulib module wcsnlen for portability");
605 /* Copy SRC to DEST. */
608 _GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
610 _GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
611 _GL_CXXALIASWARN (wcscpy);
612 #elif defined GNULIB_POSIXCHECK
614 # if HAVE_RAW_DECL_WCSCPY
615 _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
616 "use gnulib module wcscpy for portability");
621 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
624 _GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
626 _GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
627 _GL_CXXALIASWARN (wcpcpy);
628 #elif defined GNULIB_POSIXCHECK
630 # if HAVE_RAW_DECL_WCPCPY
631 _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
632 "use gnulib module wcpcpy for portability");
637 /* Copy no more than N wide characters of SRC to DEST. */
640 _GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
641 (wchar_t *dest, const wchar_t *src, size_t n));
643 _GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
644 (wchar_t *dest, const wchar_t *src, size_t n));
645 _GL_CXXALIASWARN (wcsncpy);
646 #elif defined GNULIB_POSIXCHECK
648 # if HAVE_RAW_DECL_WCSNCPY
649 _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
650 "use gnulib module wcsncpy for portability");
655 /* Copy no more than N characters of SRC to DEST, returning the address of
656 the last character written into DEST. */
659 _GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
660 (wchar_t *dest, const wchar_t *src, size_t n));
662 _GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
663 (wchar_t *dest, const wchar_t *src, size_t n));
664 _GL_CXXALIASWARN (wcpncpy);
665 #elif defined GNULIB_POSIXCHECK
667 # if HAVE_RAW_DECL_WCPNCPY
668 _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
669 "use gnulib module wcpncpy for portability");
674 /* Append SRC onto DEST. */
677 _GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
679 _GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
680 _GL_CXXALIASWARN (wcscat);
681 #elif defined GNULIB_POSIXCHECK
683 # if HAVE_RAW_DECL_WCSCAT
684 _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
685 "use gnulib module wcscat for portability");
690 /* Append no more than N wide characters of SRC onto DEST. */
693 _GL_FUNCDECL_SYS (wcsncat, wchar_t *,
694 (wchar_t *dest, const wchar_t *src, size_t n));
696 _GL_CXXALIAS_SYS (wcsncat, wchar_t *,
697 (wchar_t *dest, const wchar_t *src, size_t n));
698 _GL_CXXALIASWARN (wcsncat);
699 #elif defined GNULIB_POSIXCHECK
701 # if HAVE_RAW_DECL_WCSNCAT
702 _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
703 "use gnulib module wcsncat for portability");
708 /* Compare S1 and S2. */
711 _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)
714 _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
715 _GL_CXXALIASWARN (wcscmp);
716 #elif defined GNULIB_POSIXCHECK
718 # if HAVE_RAW_DECL_WCSCMP
719 _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
720 "use gnulib module wcscmp for portability");
725 /* Compare no more than N wide characters of S1 and S2. */
728 _GL_FUNCDECL_SYS (wcsncmp, int,
729 (const wchar_t *s1, const wchar_t *s2, size_t n)
732 _GL_CXXALIAS_SYS (wcsncmp, int,
733 (const wchar_t *s1, const wchar_t *s2, size_t n));
734 _GL_CXXALIASWARN (wcsncmp);
735 #elif defined GNULIB_POSIXCHECK
737 # if HAVE_RAW_DECL_WCSNCMP
738 _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
739 "use gnulib module wcsncmp for portability");
744 /* Compare S1 and S2, ignoring case. */
745 #if @GNULIB_WCSCASECMP@
746 # if !@HAVE_WCSCASECMP@
747 _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)
750 _GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
751 _GL_CXXALIASWARN (wcscasecmp);
752 #elif defined GNULIB_POSIXCHECK
754 # if HAVE_RAW_DECL_WCSCASECMP
755 _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
756 "use gnulib module wcscasecmp for portability");
761 /* Compare no more than N chars of S1 and S2, ignoring case. */
762 #if @GNULIB_WCSNCASECMP@
763 # if !@HAVE_WCSNCASECMP@
764 _GL_FUNCDECL_SYS (wcsncasecmp, int,
765 (const wchar_t *s1, const wchar_t *s2, size_t n)
768 _GL_CXXALIAS_SYS (wcsncasecmp, int,
769 (const wchar_t *s1, const wchar_t *s2, size_t n));
770 _GL_CXXALIASWARN (wcsncasecmp);
771 #elif defined GNULIB_POSIXCHECK
773 # if HAVE_RAW_DECL_WCSNCASECMP
774 _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
775 "use gnulib module wcsncasecmp for portability");
780 /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
781 category of the current locale. */
784 _GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
786 _GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
787 _GL_CXXALIASWARN (wcscoll);
788 #elif defined GNULIB_POSIXCHECK
790 # if HAVE_RAW_DECL_WCSCOLL
791 _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
792 "use gnulib module wcscoll for portability");
797 /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
798 to two transformed strings the result is the as applying 'wcscoll' to the
802 _GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
804 _GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
805 _GL_CXXALIASWARN (wcsxfrm);
806 #elif defined GNULIB_POSIXCHECK
808 # if HAVE_RAW_DECL_WCSXFRM
809 _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
810 "use gnulib module wcsxfrm for portability");
815 /* Duplicate S, returning an identical malloc'd string. */
818 _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s));
820 _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
821 _GL_CXXALIASWARN (wcsdup);
822 #elif defined GNULIB_POSIXCHECK
824 # if HAVE_RAW_DECL_WCSDUP
825 _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
826 "use gnulib module wcsdup for portability");
831 /* Find the first occurrence of WC in WCS. */
834 _GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
837 /* On some systems, this function is defined as an overloaded function:
839 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
840 wchar_t * std::wcschr (wchar_t *, wchar_t);
842 _GL_CXXALIAS_SYS_CAST2 (wcschr,
843 wchar_t *, (const wchar_t *, wchar_t),
844 const wchar_t *, (const wchar_t *, wchar_t));
845 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
846 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
847 _GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
848 _GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
850 _GL_CXXALIASWARN (wcschr);
852 #elif defined GNULIB_POSIXCHECK
854 # if HAVE_RAW_DECL_WCSCHR
855 _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
856 "use gnulib module wcschr for portability");
861 /* Find the last occurrence of WC in WCS. */
864 _GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
867 /* On some systems, this function is defined as an overloaded function:
869 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
870 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
872 _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
873 wchar_t *, (const wchar_t *, wchar_t),
874 const wchar_t *, (const wchar_t *, wchar_t));
875 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
876 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
877 _GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
878 _GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
880 _GL_CXXALIASWARN (wcsrchr);
882 #elif defined GNULIB_POSIXCHECK
884 # if HAVE_RAW_DECL_WCSRCHR
885 _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
886 "use gnulib module wcsrchr for portability");
891 /* Return the length of the initial segmet of WCS which consists entirely
892 of wide characters not in REJECT. */
895 _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)
898 _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
899 _GL_CXXALIASWARN (wcscspn);
900 #elif defined GNULIB_POSIXCHECK
902 # if HAVE_RAW_DECL_WCSCSPN
903 _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
904 "use gnulib module wcscspn for portability");
909 /* Return the length of the initial segmet of WCS which consists entirely
910 of wide characters in ACCEPT. */
913 _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)
916 _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
917 _GL_CXXALIASWARN (wcsspn);
918 #elif defined GNULIB_POSIXCHECK
920 # if HAVE_RAW_DECL_WCSSPN
921 _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
922 "use gnulib module wcsspn for portability");
927 /* Find the first occurrence in WCS of any character in ACCEPT. */
930 _GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
931 (const wchar_t *wcs, const wchar_t *accept)
934 /* On some systems, this function is defined as an overloaded function:
936 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
937 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
939 _GL_CXXALIAS_SYS_CAST2 (wcspbrk,
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 (wcspbrk, wchar_t *,
945 (wchar_t *wcs, const wchar_t *accept));
946 _GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
947 (const wchar_t *wcs, const wchar_t *accept));
949 _GL_CXXALIASWARN (wcspbrk);
951 #elif defined GNULIB_POSIXCHECK
953 # if HAVE_RAW_DECL_WCSPBRK
954 _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
955 "use gnulib module wcspbrk for portability");
960 /* Find the first occurrence of NEEDLE in HAYSTACK. */
963 _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
964 (const wchar_t *haystack, const wchar_t *needle)
967 /* On some systems, this function is defined as an overloaded function:
969 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
970 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
972 _GL_CXXALIAS_SYS_CAST2 (wcsstr,
973 wchar_t *, (const wchar_t *, const wchar_t *),
974 const wchar_t *, (const wchar_t *, const wchar_t *));
975 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
976 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
977 _GL_CXXALIASWARN1 (wcsstr, wchar_t *,
978 (wchar_t *haystack, const wchar_t *needle));
979 _GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
980 (const wchar_t *haystack, const wchar_t *needle));
982 _GL_CXXALIASWARN (wcsstr);
984 #elif defined GNULIB_POSIXCHECK
986 # if HAVE_RAW_DECL_WCSSTR
987 _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
988 "use gnulib module wcsstr for portability");
993 /* Divide WCS into tokens separated by characters in DELIM. */
996 _GL_FUNCDECL_SYS (wcstok, wchar_t *,
997 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
999 _GL_CXXALIAS_SYS (wcstok, wchar_t *,
1000 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
1001 _GL_CXXALIASWARN (wcstok);
1002 #elif defined GNULIB_POSIXCHECK
1004 # if HAVE_RAW_DECL_WCSTOK
1005 _GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
1006 "use gnulib module wcstok for portability");
1011 /* Determine number of column positions required for first N wide
1012 characters (or fewer if S ends before this) in S. */
1013 #if @GNULIB_WCSWIDTH@
1014 # if @REPLACE_WCSWIDTH@
1015 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1017 # define wcswidth rpl_wcswidth
1019 _GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n)
1020 _GL_ATTRIBUTE_PURE);
1021 _GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
1023 # if !@HAVE_WCSWIDTH@
1024 _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n)
1025 _GL_ATTRIBUTE_PURE);
1027 _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
1029 _GL_CXXALIASWARN (wcswidth);
1030 #elif defined GNULIB_POSIXCHECK
1032 # if HAVE_RAW_DECL_WCSWIDTH
1033 _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1034 "use gnulib module wcswidth for portability");
1039 #endif /* _@GUARD_PREFIX@_WCHAR_H */
1040 #endif /* _@GUARD_PREFIX@_WCHAR_H */