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 _GL_ALREADY_INCLUDING_WCHAR_H)
39 /* Special invocation convention:
40 - Inside glibc and uClibc header files, but not MinGW.
41 - On HP-UX 11.00 we have a sequence of nested includes
42 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
43 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
44 and once directly. In both situations 'wint_t' is not yet defined,
45 therefore we cannot provide the function overrides; instead include only
46 the system's <wchar.h>.
47 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
48 the latter includes <wchar.h>. But here, we have no way to detect whether
49 <wctype.h> is completely included or is still being included. */
51 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
54 /* Normal invocation convention. */
56 #ifndef _@GUARD_PREFIX@_WCHAR_H
58 #define _GL_ALREADY_INCLUDING_WCHAR_H
61 # include <features.h> /* for __GLIBC__ */
64 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
66 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
67 included before <wchar.h>.
68 In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
70 But avoid namespace pollution on glibc systems. */
71 #if !(defined __GLIBC__ && !defined __UCLIBC__)
79 /* Include the original <wchar.h> if it exists.
80 Some builds of uClibc lack it. */
81 /* The include_next requires a split double-inclusion guard. */
83 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
86 #undef _GL_ALREADY_INCLUDING_WCHAR_H
88 #ifndef _@GUARD_PREFIX@_WCHAR_H
89 #define _@GUARD_PREFIX@_WCHAR_H
91 /* The __attribute__ feature is available in gcc versions 2.5 and later.
92 The attribute __pure__ was added in gcc 2.96. */
93 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
94 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
96 # define _GL_ATTRIBUTE_PURE /* empty */
99 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
101 /* The definition of _GL_ARG_NONNULL is copied here. */
103 /* The definition of _GL_WARN_ON_USE is copied here. */
106 /* Define wint_t and WEOF. (Also done in wctype.in.h.) */
107 #if !@HAVE_WINT_T@ && !defined wint_t
113 /* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>.
114 This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be
115 "unchanged by default argument promotions". Override it. */
116 # if defined _MSC_VER
117 # if !GNULIB_defined_wint_t
118 # include <crtdefs.h>
119 typedef unsigned int rpl_wint_t;
121 # define wint_t rpl_wint_t
122 # define GNULIB_defined_wint_t 1
126 # define WEOF ((wint_t) -1)
131 /* Override mbstate_t if it is too small.
132 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
133 implementing mbrtowc for encodings like UTF-8. */
134 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
135 # if !GNULIB_defined_mbstate_t
136 typedef int rpl_mbstate_t;
138 # define mbstate_t rpl_mbstate_t
139 # define GNULIB_defined_mbstate_t 1
144 /* Convert a single-byte character to a wide character. */
147 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
149 # define btowc rpl_btowc
151 _GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
152 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
155 _GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
157 _GL_CXXALIAS_SYS (btowc, wint_t, (int c));
159 _GL_CXXALIASWARN (btowc);
160 #elif defined GNULIB_POSIXCHECK
162 # if HAVE_RAW_DECL_BTOWC
163 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
164 "use gnulib module btowc for portability");
169 /* Convert a wide character to a single-byte character. */
172 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
174 # define wctob rpl_wctob
176 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
177 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
179 # if !defined wctob && !@HAVE_DECL_WCTOB@
180 /* wctob is provided by gnulib, or wctob exists but is not declared. */
181 _GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
183 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
185 _GL_CXXALIASWARN (wctob);
186 #elif defined GNULIB_POSIXCHECK
188 # if HAVE_RAW_DECL_WCTOB
189 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
190 "use gnulib module wctob for portability");
195 /* Test whether *PS is in the initial state. */
197 # if @REPLACE_MBSINIT@
198 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
200 # define mbsinit rpl_mbsinit
202 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
203 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
206 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
208 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
210 _GL_CXXALIASWARN (mbsinit);
211 #elif defined GNULIB_POSIXCHECK
213 # if HAVE_RAW_DECL_MBSINIT
214 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
215 "use gnulib module mbsinit for portability");
220 /* Convert a multibyte character to a wide character. */
222 # if @REPLACE_MBRTOWC@
223 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
225 # define mbrtowc rpl_mbrtowc
227 _GL_FUNCDECL_RPL (mbrtowc, size_t,
228 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
229 _GL_CXXALIAS_RPL (mbrtowc, size_t,
230 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
233 _GL_FUNCDECL_SYS (mbrtowc, size_t,
234 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
236 _GL_CXXALIAS_SYS (mbrtowc, size_t,
237 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
239 _GL_CXXALIASWARN (mbrtowc);
240 #elif defined GNULIB_POSIXCHECK
242 # if HAVE_RAW_DECL_MBRTOWC
243 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
244 "use gnulib module mbrtowc for portability");
249 /* Recognize a multibyte character. */
251 # if @REPLACE_MBRLEN@
252 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
254 # define mbrlen rpl_mbrlen
256 _GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
257 _GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
260 _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
262 _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
264 _GL_CXXALIASWARN (mbrlen);
265 #elif defined GNULIB_POSIXCHECK
267 # if HAVE_RAW_DECL_MBRLEN
268 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
269 "use gnulib module mbrlen for portability");
274 /* Convert a string to a wide string. */
275 #if @GNULIB_MBSRTOWCS@
276 # if @REPLACE_MBSRTOWCS@
277 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
279 # define mbsrtowcs rpl_mbsrtowcs
281 _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
282 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
283 _GL_ARG_NONNULL ((2)));
284 _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
285 (wchar_t *dest, const char **srcp, size_t len,
288 # if !@HAVE_MBSRTOWCS@
289 _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
290 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
291 _GL_ARG_NONNULL ((2)));
293 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
294 (wchar_t *dest, const char **srcp, size_t len,
297 _GL_CXXALIASWARN (mbsrtowcs);
298 #elif defined GNULIB_POSIXCHECK
300 # if HAVE_RAW_DECL_MBSRTOWCS
301 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
302 "use gnulib module mbsrtowcs for portability");
307 /* Convert a string to a wide string. */
308 #if @GNULIB_MBSNRTOWCS@
309 # if @REPLACE_MBSNRTOWCS@
310 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
312 # define mbsnrtowcs rpl_mbsnrtowcs
314 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
315 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
317 _GL_ARG_NONNULL ((2)));
318 _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
319 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
322 # if !@HAVE_MBSNRTOWCS@
323 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
324 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
326 _GL_ARG_NONNULL ((2)));
328 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
329 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
332 _GL_CXXALIASWARN (mbsnrtowcs);
333 #elif defined GNULIB_POSIXCHECK
335 # if HAVE_RAW_DECL_MBSNRTOWCS
336 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
337 "use gnulib module mbsnrtowcs for portability");
342 /* Convert a wide character to a multibyte character. */
344 # if @REPLACE_WCRTOMB@
345 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
347 # define wcrtomb rpl_wcrtomb
349 _GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
350 _GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
353 _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
355 _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
357 _GL_CXXALIASWARN (wcrtomb);
358 #elif defined GNULIB_POSIXCHECK
360 # if HAVE_RAW_DECL_WCRTOMB
361 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
362 "use gnulib module wcrtomb for portability");
367 /* Convert a wide string to a string. */
368 #if @GNULIB_WCSRTOMBS@
369 # if @REPLACE_WCSRTOMBS@
370 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
372 # define wcsrtombs rpl_wcsrtombs
374 _GL_FUNCDECL_RPL (wcsrtombs, size_t,
375 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
376 _GL_ARG_NONNULL ((2)));
377 _GL_CXXALIAS_RPL (wcsrtombs, size_t,
378 (char *dest, const wchar_t **srcp, size_t len,
381 # if !@HAVE_WCSRTOMBS@
382 _GL_FUNCDECL_SYS (wcsrtombs, size_t,
383 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
384 _GL_ARG_NONNULL ((2)));
386 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
387 (char *dest, const wchar_t **srcp, size_t len,
390 _GL_CXXALIASWARN (wcsrtombs);
391 #elif defined GNULIB_POSIXCHECK
393 # if HAVE_RAW_DECL_WCSRTOMBS
394 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
395 "use gnulib module wcsrtombs for portability");
400 /* Convert a wide string to a string. */
401 #if @GNULIB_WCSNRTOMBS@
402 # if @REPLACE_WCSNRTOMBS@
403 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
405 # define wcsnrtombs rpl_wcsnrtombs
407 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
408 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
410 _GL_ARG_NONNULL ((2)));
411 _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
412 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
415 # if !@HAVE_WCSNRTOMBS@
416 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
417 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
419 _GL_ARG_NONNULL ((2)));
421 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
422 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
425 _GL_CXXALIASWARN (wcsnrtombs);
426 #elif defined GNULIB_POSIXCHECK
428 # if HAVE_RAW_DECL_WCSNRTOMBS
429 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
430 "use gnulib module wcsnrtombs for portability");
435 /* Return the number of screen columns needed for WC. */
437 # if @REPLACE_WCWIDTH@
438 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
440 # define wcwidth rpl_wcwidth
442 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
443 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
445 # if !@HAVE_DECL_WCWIDTH@
446 /* wcwidth exists but is not declared. */
447 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
448 # elif defined __KLIBC__
449 /* On OS/2 kLIBC, wcwidth is a macro that expands to the name of a
450 static inline function. The implementation of wcwidth in wcwidth.c
451 causes a "conflicting types" error. */
454 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
456 _GL_CXXALIASWARN (wcwidth);
457 #elif defined GNULIB_POSIXCHECK
459 # if HAVE_RAW_DECL_WCWIDTH
460 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
461 "use gnulib module wcwidth for portability");
466 /* Search N wide characters of S for C. */
469 _GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n)
472 /* On some systems, this function is defined as an overloaded function:
474 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
475 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
477 _GL_CXXALIAS_SYS_CAST2 (wmemchr,
478 wchar_t *, (const wchar_t *, wchar_t, size_t),
479 const wchar_t *, (const wchar_t *, wchar_t, size_t));
480 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
481 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
482 _GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
483 _GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
484 (const wchar_t *s, wchar_t c, size_t n));
486 _GL_CXXALIASWARN (wmemchr);
488 #elif defined GNULIB_POSIXCHECK
490 # if HAVE_RAW_DECL_WMEMCHR
491 _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
492 "use gnulib module wmemchr for portability");
497 /* Compare N wide characters of S1 and S2. */
500 _GL_FUNCDECL_SYS (wmemcmp, int,
501 (const wchar_t *s1, const wchar_t *s2, size_t n)
504 _GL_CXXALIAS_SYS (wmemcmp, int,
505 (const wchar_t *s1, const wchar_t *s2, size_t n));
506 _GL_CXXALIASWARN (wmemcmp);
507 #elif defined GNULIB_POSIXCHECK
509 # if HAVE_RAW_DECL_WMEMCMP
510 _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
511 "use gnulib module wmemcmp for portability");
516 /* Copy N wide characters of SRC to DEST. */
519 _GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
520 (wchar_t *dest, const wchar_t *src, size_t n));
522 _GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
523 (wchar_t *dest, const wchar_t *src, size_t n));
524 _GL_CXXALIASWARN (wmemcpy);
525 #elif defined GNULIB_POSIXCHECK
527 # if HAVE_RAW_DECL_WMEMCPY
528 _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
529 "use gnulib module wmemcpy for portability");
534 /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
535 overlapping memory areas. */
536 #if @GNULIB_WMEMMOVE@
537 # if !@HAVE_WMEMMOVE@
538 _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
539 (wchar_t *dest, const wchar_t *src, size_t n));
541 _GL_CXXALIAS_SYS (wmemmove, wchar_t *,
542 (wchar_t *dest, const wchar_t *src, size_t n));
543 _GL_CXXALIASWARN (wmemmove);
544 #elif defined GNULIB_POSIXCHECK
546 # if HAVE_RAW_DECL_WMEMMOVE
547 _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
548 "use gnulib module wmemmove for portability");
553 /* Set N wide characters of S to C. */
556 _GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
558 _GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
559 _GL_CXXALIASWARN (wmemset);
560 #elif defined GNULIB_POSIXCHECK
562 # if HAVE_RAW_DECL_WMEMSET
563 _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
564 "use gnulib module wmemset for portability");
569 /* Return the number of wide characters in S. */
572 _GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE);
574 _GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
575 _GL_CXXALIASWARN (wcslen);
576 #elif defined GNULIB_POSIXCHECK
578 # if HAVE_RAW_DECL_WCSLEN
579 _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
580 "use gnulib module wcslen for portability");
585 /* Return the number of wide characters in S, but at most MAXLEN. */
588 _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)
591 _GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
592 _GL_CXXALIASWARN (wcsnlen);
593 #elif defined GNULIB_POSIXCHECK
595 # if HAVE_RAW_DECL_WCSNLEN
596 _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
597 "use gnulib module wcsnlen for portability");
602 /* Copy SRC to DEST. */
605 _GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
607 _GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
608 _GL_CXXALIASWARN (wcscpy);
609 #elif defined GNULIB_POSIXCHECK
611 # if HAVE_RAW_DECL_WCSCPY
612 _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
613 "use gnulib module wcscpy for portability");
618 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
621 _GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
623 _GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
624 _GL_CXXALIASWARN (wcpcpy);
625 #elif defined GNULIB_POSIXCHECK
627 # if HAVE_RAW_DECL_WCPCPY
628 _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
629 "use gnulib module wcpcpy for portability");
634 /* Copy no more than N wide characters of SRC to DEST. */
637 _GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
638 (wchar_t *dest, const wchar_t *src, size_t n));
640 _GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
641 (wchar_t *dest, const wchar_t *src, size_t n));
642 _GL_CXXALIASWARN (wcsncpy);
643 #elif defined GNULIB_POSIXCHECK
645 # if HAVE_RAW_DECL_WCSNCPY
646 _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
647 "use gnulib module wcsncpy for portability");
652 /* Copy no more than N characters of SRC to DEST, returning the address of
653 the last character written into DEST. */
656 _GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
657 (wchar_t *dest, const wchar_t *src, size_t n));
659 _GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
660 (wchar_t *dest, const wchar_t *src, size_t n));
661 _GL_CXXALIASWARN (wcpncpy);
662 #elif defined GNULIB_POSIXCHECK
664 # if HAVE_RAW_DECL_WCPNCPY
665 _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
666 "use gnulib module wcpncpy for portability");
671 /* Append SRC onto DEST. */
674 _GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
676 _GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
677 _GL_CXXALIASWARN (wcscat);
678 #elif defined GNULIB_POSIXCHECK
680 # if HAVE_RAW_DECL_WCSCAT
681 _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
682 "use gnulib module wcscat for portability");
687 /* Append no more than N wide characters of SRC onto DEST. */
690 _GL_FUNCDECL_SYS (wcsncat, wchar_t *,
691 (wchar_t *dest, const wchar_t *src, size_t n));
693 _GL_CXXALIAS_SYS (wcsncat, wchar_t *,
694 (wchar_t *dest, const wchar_t *src, size_t n));
695 _GL_CXXALIASWARN (wcsncat);
696 #elif defined GNULIB_POSIXCHECK
698 # if HAVE_RAW_DECL_WCSNCAT
699 _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
700 "use gnulib module wcsncat for portability");
705 /* Compare S1 and S2. */
708 _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)
711 _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
712 _GL_CXXALIASWARN (wcscmp);
713 #elif defined GNULIB_POSIXCHECK
715 # if HAVE_RAW_DECL_WCSCMP
716 _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
717 "use gnulib module wcscmp for portability");
722 /* Compare no more than N wide characters of S1 and S2. */
725 _GL_FUNCDECL_SYS (wcsncmp, int,
726 (const wchar_t *s1, const wchar_t *s2, size_t n)
729 _GL_CXXALIAS_SYS (wcsncmp, int,
730 (const wchar_t *s1, const wchar_t *s2, size_t n));
731 _GL_CXXALIASWARN (wcsncmp);
732 #elif defined GNULIB_POSIXCHECK
734 # if HAVE_RAW_DECL_WCSNCMP
735 _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
736 "use gnulib module wcsncmp for portability");
741 /* Compare S1 and S2, ignoring case. */
742 #if @GNULIB_WCSCASECMP@
743 # if !@HAVE_WCSCASECMP@
744 _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)
747 _GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
748 _GL_CXXALIASWARN (wcscasecmp);
749 #elif defined GNULIB_POSIXCHECK
751 # if HAVE_RAW_DECL_WCSCASECMP
752 _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
753 "use gnulib module wcscasecmp for portability");
758 /* Compare no more than N chars of S1 and S2, ignoring case. */
759 #if @GNULIB_WCSNCASECMP@
760 # if !@HAVE_WCSNCASECMP@
761 _GL_FUNCDECL_SYS (wcsncasecmp, int,
762 (const wchar_t *s1, const wchar_t *s2, size_t n)
765 _GL_CXXALIAS_SYS (wcsncasecmp, int,
766 (const wchar_t *s1, const wchar_t *s2, size_t n));
767 _GL_CXXALIASWARN (wcsncasecmp);
768 #elif defined GNULIB_POSIXCHECK
770 # if HAVE_RAW_DECL_WCSNCASECMP
771 _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
772 "use gnulib module wcsncasecmp for portability");
777 /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
778 category of the current locale. */
781 _GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
783 _GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
784 _GL_CXXALIASWARN (wcscoll);
785 #elif defined GNULIB_POSIXCHECK
787 # if HAVE_RAW_DECL_WCSCOLL
788 _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
789 "use gnulib module wcscoll for portability");
794 /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
795 to two transformed strings the result is the as applying 'wcscoll' to the
799 _GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
801 _GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
802 _GL_CXXALIASWARN (wcsxfrm);
803 #elif defined GNULIB_POSIXCHECK
805 # if HAVE_RAW_DECL_WCSXFRM
806 _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
807 "use gnulib module wcsxfrm for portability");
812 /* Duplicate S, returning an identical malloc'd string. */
815 _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s));
817 _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
818 _GL_CXXALIASWARN (wcsdup);
819 #elif defined GNULIB_POSIXCHECK
821 # if HAVE_RAW_DECL_WCSDUP
822 _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
823 "use gnulib module wcsdup for portability");
828 /* Find the first occurrence of WC in WCS. */
831 _GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
834 /* On some systems, this function is defined as an overloaded function:
836 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
837 wchar_t * std::wcschr (wchar_t *, wchar_t);
839 _GL_CXXALIAS_SYS_CAST2 (wcschr,
840 wchar_t *, (const wchar_t *, wchar_t),
841 const wchar_t *, (const wchar_t *, wchar_t));
842 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
843 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
844 _GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
845 _GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
847 _GL_CXXALIASWARN (wcschr);
849 #elif defined GNULIB_POSIXCHECK
851 # if HAVE_RAW_DECL_WCSCHR
852 _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
853 "use gnulib module wcschr for portability");
858 /* Find the last occurrence of WC in WCS. */
861 _GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
864 /* On some systems, this function is defined as an overloaded function:
866 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
867 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
869 _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
870 wchar_t *, (const wchar_t *, wchar_t),
871 const wchar_t *, (const wchar_t *, wchar_t));
872 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
873 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
874 _GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
875 _GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
877 _GL_CXXALIASWARN (wcsrchr);
879 #elif defined GNULIB_POSIXCHECK
881 # if HAVE_RAW_DECL_WCSRCHR
882 _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
883 "use gnulib module wcsrchr for portability");
888 /* Return the length of the initial segmet of WCS which consists entirely
889 of wide characters not in REJECT. */
892 _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)
895 _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
896 _GL_CXXALIASWARN (wcscspn);
897 #elif defined GNULIB_POSIXCHECK
899 # if HAVE_RAW_DECL_WCSCSPN
900 _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
901 "use gnulib module wcscspn for portability");
906 /* Return the length of the initial segmet of WCS which consists entirely
907 of wide characters in ACCEPT. */
910 _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)
913 _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
914 _GL_CXXALIASWARN (wcsspn);
915 #elif defined GNULIB_POSIXCHECK
917 # if HAVE_RAW_DECL_WCSSPN
918 _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
919 "use gnulib module wcsspn for portability");
924 /* Find the first occurrence in WCS of any character in ACCEPT. */
927 _GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
928 (const wchar_t *wcs, const wchar_t *accept)
931 /* On some systems, this function is defined as an overloaded function:
933 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
934 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
936 _GL_CXXALIAS_SYS_CAST2 (wcspbrk,
937 wchar_t *, (const wchar_t *, const wchar_t *),
938 const wchar_t *, (const wchar_t *, const wchar_t *));
939 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
940 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
941 _GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
942 (wchar_t *wcs, const wchar_t *accept));
943 _GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
944 (const wchar_t *wcs, const wchar_t *accept));
946 _GL_CXXALIASWARN (wcspbrk);
948 #elif defined GNULIB_POSIXCHECK
950 # if HAVE_RAW_DECL_WCSPBRK
951 _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
952 "use gnulib module wcspbrk for portability");
957 /* Find the first occurrence of NEEDLE in HAYSTACK. */
960 _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
961 (const wchar_t *haystack, const wchar_t *needle)
964 /* On some systems, this function is defined as an overloaded function:
966 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
967 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
969 _GL_CXXALIAS_SYS_CAST2 (wcsstr,
970 wchar_t *, (const wchar_t *, const wchar_t *),
971 const wchar_t *, (const wchar_t *, const wchar_t *));
972 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
973 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
974 _GL_CXXALIASWARN1 (wcsstr, wchar_t *,
975 (wchar_t *haystack, const wchar_t *needle));
976 _GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
977 (const wchar_t *haystack, const wchar_t *needle));
979 _GL_CXXALIASWARN (wcsstr);
981 #elif defined GNULIB_POSIXCHECK
983 # if HAVE_RAW_DECL_WCSSTR
984 _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
985 "use gnulib module wcsstr for portability");
990 /* Divide WCS into tokens separated by characters in DELIM. */
993 _GL_FUNCDECL_SYS (wcstok, wchar_t *,
994 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
996 _GL_CXXALIAS_SYS (wcstok, wchar_t *,
997 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
998 _GL_CXXALIASWARN (wcstok);
999 #elif defined GNULIB_POSIXCHECK
1001 # if HAVE_RAW_DECL_WCSTOK
1002 _GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
1003 "use gnulib module wcstok for portability");
1008 /* Determine number of column positions required for first N wide
1009 characters (or fewer if S ends before this) in S. */
1010 #if @GNULIB_WCSWIDTH@
1011 # if @REPLACE_WCSWIDTH@
1012 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1014 # define wcswidth rpl_wcswidth
1016 _GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n)
1017 _GL_ATTRIBUTE_PURE);
1018 _GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
1020 # if !@HAVE_WCSWIDTH@
1021 _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n)
1022 _GL_ATTRIBUTE_PURE);
1024 _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
1026 _GL_CXXALIASWARN (wcswidth);
1027 #elif defined GNULIB_POSIXCHECK
1029 # if HAVE_RAW_DECL_WCSWIDTH
1030 _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1031 "use gnulib module wcswidth for portability");
1036 #endif /* _@GUARD_PREFIX@_WCHAR_H */
1037 #endif /* _@GUARD_PREFIX@_WCHAR_H */