1 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
3 Copyright (C) 2007-2018 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, see <https://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__) \
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 /* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
117 <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
118 wint_t must be "unchanged by default argument promotions". Override it. */
119 # if @GNULIB_OVERRIDES_WINT_T@
120 # if !GNULIB_defined_wint_t
121 # if @HAVE_CRTDEFS_H@
122 # include <crtdefs.h>
126 typedef unsigned int rpl_wint_t
;
128 # define wint_t rpl_wint_t
129 # define GNULIB_defined_wint_t 1
133 # define WEOF ((wint_t) -1)
138 /* Override mbstate_t if it is too small.
139 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
140 implementing mbrtowc for encodings like UTF-8. */
141 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
142 # if !GNULIB_defined_mbstate_t
143 typedef int rpl_mbstate_t
;
145 # define mbstate_t rpl_mbstate_t
146 # define GNULIB_defined_mbstate_t 1
151 /* Convert a single-byte character to a wide character. */
154 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
156 # define btowc rpl_btowc
158 _GL_FUNCDECL_RPL (btowc
, wint_t, (int c
) _GL_ATTRIBUTE_PURE
);
159 _GL_CXXALIAS_RPL (btowc
, wint_t, (int c
));
162 _GL_FUNCDECL_SYS (btowc
, wint_t, (int c
) _GL_ATTRIBUTE_PURE
);
164 _GL_CXXALIAS_SYS (btowc
, wint_t, (int c
));
166 _GL_CXXALIASWARN (btowc
);
167 #elif defined GNULIB_POSIXCHECK
169 # if HAVE_RAW_DECL_BTOWC
170 _GL_WARN_ON_USE (btowc
, "btowc is unportable - "
171 "use gnulib module btowc for portability");
176 /* Convert a wide character to a single-byte character. */
179 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
181 # define wctob rpl_wctob
183 _GL_FUNCDECL_RPL (wctob
, int, (wint_t wc
) _GL_ATTRIBUTE_PURE
);
184 _GL_CXXALIAS_RPL (wctob
, int, (wint_t wc
));
186 # if !defined wctob && !@HAVE_DECL_WCTOB@
187 /* wctob is provided by gnulib, or wctob exists but is not declared. */
188 _GL_FUNCDECL_SYS (wctob
, int, (wint_t wc
) _GL_ATTRIBUTE_PURE
);
190 _GL_CXXALIAS_SYS (wctob
, int, (wint_t wc
));
192 _GL_CXXALIASWARN (wctob
);
193 #elif defined GNULIB_POSIXCHECK
195 # if HAVE_RAW_DECL_WCTOB
196 _GL_WARN_ON_USE (wctob
, "wctob is unportable - "
197 "use gnulib module wctob for portability");
202 /* Test whether *PS is in the initial state. */
204 # if @REPLACE_MBSINIT@
205 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
207 # define mbsinit rpl_mbsinit
209 _GL_FUNCDECL_RPL (mbsinit
, int, (const mbstate_t *ps
));
210 _GL_CXXALIAS_RPL (mbsinit
, int, (const mbstate_t *ps
));
213 _GL_FUNCDECL_SYS (mbsinit
, int, (const mbstate_t *ps
));
215 _GL_CXXALIAS_SYS (mbsinit
, int, (const mbstate_t *ps
));
217 _GL_CXXALIASWARN (mbsinit
);
218 #elif defined GNULIB_POSIXCHECK
220 # if HAVE_RAW_DECL_MBSINIT
221 _GL_WARN_ON_USE (mbsinit
, "mbsinit is unportable - "
222 "use gnulib module mbsinit for portability");
227 /* Convert a multibyte character to a wide character. */
229 # if @REPLACE_MBRTOWC@
230 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
232 # define mbrtowc rpl_mbrtowc
234 _GL_FUNCDECL_RPL (mbrtowc
, size_t,
235 (wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
));
236 _GL_CXXALIAS_RPL (mbrtowc
, size_t,
237 (wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
));
240 _GL_FUNCDECL_SYS (mbrtowc
, size_t,
241 (wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
));
243 _GL_CXXALIAS_SYS (mbrtowc
, size_t,
244 (wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
));
246 _GL_CXXALIASWARN (mbrtowc
);
247 #elif defined GNULIB_POSIXCHECK
249 # if HAVE_RAW_DECL_MBRTOWC
250 _GL_WARN_ON_USE (mbrtowc
, "mbrtowc is unportable - "
251 "use gnulib module mbrtowc for portability");
256 /* Recognize a multibyte character. */
258 # if @REPLACE_MBRLEN@
259 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
261 # define mbrlen rpl_mbrlen
263 _GL_FUNCDECL_RPL (mbrlen
, size_t, (const char *s
, size_t n
, mbstate_t *ps
));
264 _GL_CXXALIAS_RPL (mbrlen
, size_t, (const char *s
, size_t n
, mbstate_t *ps
));
267 _GL_FUNCDECL_SYS (mbrlen
, size_t, (const char *s
, size_t n
, mbstate_t *ps
));
269 _GL_CXXALIAS_SYS (mbrlen
, size_t, (const char *s
, size_t n
, mbstate_t *ps
));
271 _GL_CXXALIASWARN (mbrlen
);
272 #elif defined GNULIB_POSIXCHECK
274 # if HAVE_RAW_DECL_MBRLEN
275 _GL_WARN_ON_USE (mbrlen
, "mbrlen is unportable - "
276 "use gnulib module mbrlen for portability");
281 /* Convert a string to a wide string. */
282 #if @GNULIB_MBSRTOWCS@
283 # if @REPLACE_MBSRTOWCS@
284 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
286 # define mbsrtowcs rpl_mbsrtowcs
288 _GL_FUNCDECL_RPL (mbsrtowcs
, size_t,
289 (wchar_t *dest
, const char **srcp
, size_t len
, mbstate_t *ps
)
290 _GL_ARG_NONNULL ((2)));
291 _GL_CXXALIAS_RPL (mbsrtowcs
, size_t,
292 (wchar_t *dest
, const char **srcp
, size_t len
,
295 # if !@HAVE_MBSRTOWCS@
296 _GL_FUNCDECL_SYS (mbsrtowcs
, size_t,
297 (wchar_t *dest
, const char **srcp
, size_t len
, mbstate_t *ps
)
298 _GL_ARG_NONNULL ((2)));
300 _GL_CXXALIAS_SYS (mbsrtowcs
, size_t,
301 (wchar_t *dest
, const char **srcp
, size_t len
,
304 _GL_CXXALIASWARN (mbsrtowcs
);
305 #elif defined GNULIB_POSIXCHECK
307 # if HAVE_RAW_DECL_MBSRTOWCS
308 _GL_WARN_ON_USE (mbsrtowcs
, "mbsrtowcs is unportable - "
309 "use gnulib module mbsrtowcs for portability");
314 /* Convert a string to a wide string. */
315 #if @GNULIB_MBSNRTOWCS@
316 # if @REPLACE_MBSNRTOWCS@
317 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
319 # define mbsnrtowcs rpl_mbsnrtowcs
321 _GL_FUNCDECL_RPL (mbsnrtowcs
, size_t,
322 (wchar_t *dest
, const char **srcp
, size_t srclen
, size_t len
,
324 _GL_ARG_NONNULL ((2)));
325 _GL_CXXALIAS_RPL (mbsnrtowcs
, size_t,
326 (wchar_t *dest
, const char **srcp
, size_t srclen
, size_t len
,
329 # if !@HAVE_MBSNRTOWCS@
330 _GL_FUNCDECL_SYS (mbsnrtowcs
, size_t,
331 (wchar_t *dest
, const char **srcp
, size_t srclen
, size_t len
,
333 _GL_ARG_NONNULL ((2)));
335 _GL_CXXALIAS_SYS (mbsnrtowcs
, size_t,
336 (wchar_t *dest
, const char **srcp
, size_t srclen
, size_t len
,
339 _GL_CXXALIASWARN (mbsnrtowcs
);
340 #elif defined GNULIB_POSIXCHECK
342 # if HAVE_RAW_DECL_MBSNRTOWCS
343 _GL_WARN_ON_USE (mbsnrtowcs
, "mbsnrtowcs is unportable - "
344 "use gnulib module mbsnrtowcs for portability");
349 /* Convert a wide character to a multibyte character. */
351 # if @REPLACE_WCRTOMB@
352 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
354 # define wcrtomb rpl_wcrtomb
356 _GL_FUNCDECL_RPL (wcrtomb
, size_t, (char *s
, wchar_t wc
, mbstate_t *ps
));
357 _GL_CXXALIAS_RPL (wcrtomb
, size_t, (char *s
, wchar_t wc
, mbstate_t *ps
));
360 _GL_FUNCDECL_SYS (wcrtomb
, size_t, (char *s
, wchar_t wc
, mbstate_t *ps
));
362 _GL_CXXALIAS_SYS (wcrtomb
, size_t, (char *s
, wchar_t wc
, mbstate_t *ps
));
364 _GL_CXXALIASWARN (wcrtomb
);
365 #elif defined GNULIB_POSIXCHECK
367 # if HAVE_RAW_DECL_WCRTOMB
368 _GL_WARN_ON_USE (wcrtomb
, "wcrtomb is unportable - "
369 "use gnulib module wcrtomb for portability");
374 /* Convert a wide string to a string. */
375 #if @GNULIB_WCSRTOMBS@
376 # if @REPLACE_WCSRTOMBS@
377 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
379 # define wcsrtombs rpl_wcsrtombs
381 _GL_FUNCDECL_RPL (wcsrtombs
, size_t,
382 (char *dest
, const wchar_t **srcp
, size_t len
, mbstate_t *ps
)
383 _GL_ARG_NONNULL ((2)));
384 _GL_CXXALIAS_RPL (wcsrtombs
, size_t,
385 (char *dest
, const wchar_t **srcp
, size_t len
,
388 # if !@HAVE_WCSRTOMBS@
389 _GL_FUNCDECL_SYS (wcsrtombs
, size_t,
390 (char *dest
, const wchar_t **srcp
, size_t len
, mbstate_t *ps
)
391 _GL_ARG_NONNULL ((2)));
393 _GL_CXXALIAS_SYS (wcsrtombs
, size_t,
394 (char *dest
, const wchar_t **srcp
, size_t len
,
397 _GL_CXXALIASWARN (wcsrtombs
);
398 #elif defined GNULIB_POSIXCHECK
400 # if HAVE_RAW_DECL_WCSRTOMBS
401 _GL_WARN_ON_USE (wcsrtombs
, "wcsrtombs is unportable - "
402 "use gnulib module wcsrtombs for portability");
407 /* Convert a wide string to a string. */
408 #if @GNULIB_WCSNRTOMBS@
409 # if @REPLACE_WCSNRTOMBS@
410 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
412 # define wcsnrtombs rpl_wcsnrtombs
414 _GL_FUNCDECL_RPL (wcsnrtombs
, size_t,
415 (char *dest
, const wchar_t **srcp
, size_t srclen
, size_t len
,
417 _GL_ARG_NONNULL ((2)));
418 _GL_CXXALIAS_RPL (wcsnrtombs
, size_t,
419 (char *dest
, const wchar_t **srcp
, size_t srclen
, size_t len
,
422 # if !@HAVE_WCSNRTOMBS@
423 _GL_FUNCDECL_SYS (wcsnrtombs
, size_t,
424 (char *dest
, const wchar_t **srcp
, size_t srclen
, size_t len
,
426 _GL_ARG_NONNULL ((2)));
428 _GL_CXXALIAS_SYS (wcsnrtombs
, size_t,
429 (char *dest
, const wchar_t **srcp
, size_t srclen
, size_t len
,
432 _GL_CXXALIASWARN (wcsnrtombs
);
433 #elif defined GNULIB_POSIXCHECK
435 # if HAVE_RAW_DECL_WCSNRTOMBS
436 _GL_WARN_ON_USE (wcsnrtombs
, "wcsnrtombs is unportable - "
437 "use gnulib module wcsnrtombs for portability");
442 /* Return the number of screen columns needed for WC. */
444 # if @REPLACE_WCWIDTH@
445 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
447 # define wcwidth rpl_wcwidth
449 _GL_FUNCDECL_RPL (wcwidth
, int, (wchar_t) _GL_ATTRIBUTE_PURE
);
450 _GL_CXXALIAS_RPL (wcwidth
, int, (wchar_t));
452 # if !@HAVE_DECL_WCWIDTH@
453 /* wcwidth exists but is not declared. */
454 _GL_FUNCDECL_SYS (wcwidth
, int, (wchar_t) _GL_ATTRIBUTE_PURE
);
456 _GL_CXXALIAS_SYS (wcwidth
, int, (wchar_t));
458 _GL_CXXALIASWARN (wcwidth
);
459 #elif defined GNULIB_POSIXCHECK
461 # if HAVE_RAW_DECL_WCWIDTH
462 _GL_WARN_ON_USE (wcwidth
, "wcwidth is unportable - "
463 "use gnulib module wcwidth for portability");
468 /* Search N wide characters of S for C. */
471 _GL_FUNCDECL_SYS (wmemchr
, wchar_t *, (const wchar_t *s
, wchar_t c
, size_t n
)
474 /* On some systems, this function is defined as an overloaded function:
476 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
477 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
479 _GL_CXXALIAS_SYS_CAST2 (wmemchr
,
480 wchar_t *, (const wchar_t *, wchar_t, size_t),
481 const wchar_t *, (const wchar_t *, wchar_t, size_t));
482 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
483 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
484 _GL_CXXALIASWARN1 (wmemchr
, wchar_t *, (wchar_t *s
, wchar_t c
, size_t n
));
485 _GL_CXXALIASWARN1 (wmemchr
, const wchar_t *,
486 (const wchar_t *s
, wchar_t c
, size_t n
));
488 _GL_CXXALIASWARN (wmemchr
);
490 #elif defined GNULIB_POSIXCHECK
492 # if HAVE_RAW_DECL_WMEMCHR
493 _GL_WARN_ON_USE (wmemchr
, "wmemchr is unportable - "
494 "use gnulib module wmemchr for portability");
499 /* Compare N wide characters of S1 and S2. */
502 _GL_FUNCDECL_SYS (wmemcmp
, int,
503 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
506 _GL_CXXALIAS_SYS (wmemcmp
, int,
507 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
508 _GL_CXXALIASWARN (wmemcmp
);
509 #elif defined GNULIB_POSIXCHECK
511 # if HAVE_RAW_DECL_WMEMCMP
512 _GL_WARN_ON_USE (wmemcmp
, "wmemcmp is unportable - "
513 "use gnulib module wmemcmp for portability");
518 /* Copy N wide characters of SRC to DEST. */
521 _GL_FUNCDECL_SYS (wmemcpy
, wchar_t *,
522 (wchar_t *dest
, const wchar_t *src
, size_t n
));
524 _GL_CXXALIAS_SYS (wmemcpy
, wchar_t *,
525 (wchar_t *dest
, const wchar_t *src
, size_t n
));
526 _GL_CXXALIASWARN (wmemcpy
);
527 #elif defined GNULIB_POSIXCHECK
529 # if HAVE_RAW_DECL_WMEMCPY
530 _GL_WARN_ON_USE (wmemcpy
, "wmemcpy is unportable - "
531 "use gnulib module wmemcpy for portability");
536 /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
537 overlapping memory areas. */
538 #if @GNULIB_WMEMMOVE@
539 # if !@HAVE_WMEMMOVE@
540 _GL_FUNCDECL_SYS (wmemmove
, wchar_t *,
541 (wchar_t *dest
, const wchar_t *src
, size_t n
));
543 _GL_CXXALIAS_SYS (wmemmove
, wchar_t *,
544 (wchar_t *dest
, const wchar_t *src
, size_t n
));
545 _GL_CXXALIASWARN (wmemmove
);
546 #elif defined GNULIB_POSIXCHECK
548 # if HAVE_RAW_DECL_WMEMMOVE
549 _GL_WARN_ON_USE (wmemmove
, "wmemmove is unportable - "
550 "use gnulib module wmemmove for portability");
555 /* Set N wide characters of S to C. */
558 _GL_FUNCDECL_SYS (wmemset
, wchar_t *, (wchar_t *s
, wchar_t c
, size_t n
));
560 _GL_CXXALIAS_SYS (wmemset
, wchar_t *, (wchar_t *s
, wchar_t c
, size_t n
));
561 _GL_CXXALIASWARN (wmemset
);
562 #elif defined GNULIB_POSIXCHECK
564 # if HAVE_RAW_DECL_WMEMSET
565 _GL_WARN_ON_USE (wmemset
, "wmemset is unportable - "
566 "use gnulib module wmemset for portability");
571 /* Return the number of wide characters in S. */
574 _GL_FUNCDECL_SYS (wcslen
, size_t, (const wchar_t *s
) _GL_ATTRIBUTE_PURE
);
576 _GL_CXXALIAS_SYS (wcslen
, size_t, (const wchar_t *s
));
577 _GL_CXXALIASWARN (wcslen
);
578 #elif defined GNULIB_POSIXCHECK
580 # if HAVE_RAW_DECL_WCSLEN
581 _GL_WARN_ON_USE (wcslen
, "wcslen is unportable - "
582 "use gnulib module wcslen for portability");
587 /* Return the number of wide characters in S, but at most MAXLEN. */
590 _GL_FUNCDECL_SYS (wcsnlen
, size_t, (const wchar_t *s
, size_t maxlen
)
593 _GL_CXXALIAS_SYS (wcsnlen
, size_t, (const wchar_t *s
, size_t maxlen
));
594 _GL_CXXALIASWARN (wcsnlen
);
595 #elif defined GNULIB_POSIXCHECK
597 # if HAVE_RAW_DECL_WCSNLEN
598 _GL_WARN_ON_USE (wcsnlen
, "wcsnlen is unportable - "
599 "use gnulib module wcsnlen for portability");
604 /* Copy SRC to DEST. */
607 _GL_FUNCDECL_SYS (wcscpy
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
609 _GL_CXXALIAS_SYS (wcscpy
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
610 _GL_CXXALIASWARN (wcscpy
);
611 #elif defined GNULIB_POSIXCHECK
613 # if HAVE_RAW_DECL_WCSCPY
614 _GL_WARN_ON_USE (wcscpy
, "wcscpy is unportable - "
615 "use gnulib module wcscpy for portability");
620 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
623 _GL_FUNCDECL_SYS (wcpcpy
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
625 _GL_CXXALIAS_SYS (wcpcpy
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
626 _GL_CXXALIASWARN (wcpcpy
);
627 #elif defined GNULIB_POSIXCHECK
629 # if HAVE_RAW_DECL_WCPCPY
630 _GL_WARN_ON_USE (wcpcpy
, "wcpcpy is unportable - "
631 "use gnulib module wcpcpy for portability");
636 /* Copy no more than N wide characters of SRC to DEST. */
639 _GL_FUNCDECL_SYS (wcsncpy
, wchar_t *,
640 (wchar_t *dest
, const wchar_t *src
, size_t n
));
642 _GL_CXXALIAS_SYS (wcsncpy
, wchar_t *,
643 (wchar_t *dest
, const wchar_t *src
, size_t n
));
644 _GL_CXXALIASWARN (wcsncpy
);
645 #elif defined GNULIB_POSIXCHECK
647 # if HAVE_RAW_DECL_WCSNCPY
648 _GL_WARN_ON_USE (wcsncpy
, "wcsncpy is unportable - "
649 "use gnulib module wcsncpy for portability");
654 /* Copy no more than N characters of SRC to DEST, returning the address of
655 the last character written into DEST. */
658 _GL_FUNCDECL_SYS (wcpncpy
, wchar_t *,
659 (wchar_t *dest
, const wchar_t *src
, size_t n
));
661 _GL_CXXALIAS_SYS (wcpncpy
, wchar_t *,
662 (wchar_t *dest
, const wchar_t *src
, size_t n
));
663 _GL_CXXALIASWARN (wcpncpy
);
664 #elif defined GNULIB_POSIXCHECK
666 # if HAVE_RAW_DECL_WCPNCPY
667 _GL_WARN_ON_USE (wcpncpy
, "wcpncpy is unportable - "
668 "use gnulib module wcpncpy for portability");
673 /* Append SRC onto DEST. */
676 _GL_FUNCDECL_SYS (wcscat
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
678 _GL_CXXALIAS_SYS (wcscat
, wchar_t *, (wchar_t *dest
, const wchar_t *src
));
679 _GL_CXXALIASWARN (wcscat
);
680 #elif defined GNULIB_POSIXCHECK
682 # if HAVE_RAW_DECL_WCSCAT
683 _GL_WARN_ON_USE (wcscat
, "wcscat is unportable - "
684 "use gnulib module wcscat for portability");
689 /* Append no more than N wide characters of SRC onto DEST. */
692 _GL_FUNCDECL_SYS (wcsncat
, wchar_t *,
693 (wchar_t *dest
, const wchar_t *src
, size_t n
));
695 _GL_CXXALIAS_SYS (wcsncat
, wchar_t *,
696 (wchar_t *dest
, const wchar_t *src
, size_t n
));
697 _GL_CXXALIASWARN (wcsncat
);
698 #elif defined GNULIB_POSIXCHECK
700 # if HAVE_RAW_DECL_WCSNCAT
701 _GL_WARN_ON_USE (wcsncat
, "wcsncat is unportable - "
702 "use gnulib module wcsncat for portability");
707 /* Compare S1 and S2. */
710 _GL_FUNCDECL_SYS (wcscmp
, int, (const wchar_t *s1
, const wchar_t *s2
)
713 _GL_CXXALIAS_SYS (wcscmp
, int, (const wchar_t *s1
, const wchar_t *s2
));
714 _GL_CXXALIASWARN (wcscmp
);
715 #elif defined GNULIB_POSIXCHECK
717 # if HAVE_RAW_DECL_WCSCMP
718 _GL_WARN_ON_USE (wcscmp
, "wcscmp is unportable - "
719 "use gnulib module wcscmp for portability");
724 /* Compare no more than N wide characters of S1 and S2. */
727 _GL_FUNCDECL_SYS (wcsncmp
, int,
728 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
731 _GL_CXXALIAS_SYS (wcsncmp
, int,
732 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
733 _GL_CXXALIASWARN (wcsncmp
);
734 #elif defined GNULIB_POSIXCHECK
736 # if HAVE_RAW_DECL_WCSNCMP
737 _GL_WARN_ON_USE (wcsncmp
, "wcsncmp is unportable - "
738 "use gnulib module wcsncmp for portability");
743 /* Compare S1 and S2, ignoring case. */
744 #if @GNULIB_WCSCASECMP@
745 # if !@HAVE_WCSCASECMP@
746 _GL_FUNCDECL_SYS (wcscasecmp
, int, (const wchar_t *s1
, const wchar_t *s2
)
749 _GL_CXXALIAS_SYS (wcscasecmp
, int, (const wchar_t *s1
, const wchar_t *s2
));
750 _GL_CXXALIASWARN (wcscasecmp
);
751 #elif defined GNULIB_POSIXCHECK
753 # if HAVE_RAW_DECL_WCSCASECMP
754 _GL_WARN_ON_USE (wcscasecmp
, "wcscasecmp is unportable - "
755 "use gnulib module wcscasecmp for portability");
760 /* Compare no more than N chars of S1 and S2, ignoring case. */
761 #if @GNULIB_WCSNCASECMP@
762 # if !@HAVE_WCSNCASECMP@
763 _GL_FUNCDECL_SYS (wcsncasecmp
, int,
764 (const wchar_t *s1
, const wchar_t *s2
, size_t n
)
767 _GL_CXXALIAS_SYS (wcsncasecmp
, int,
768 (const wchar_t *s1
, const wchar_t *s2
, size_t n
));
769 _GL_CXXALIASWARN (wcsncasecmp
);
770 #elif defined GNULIB_POSIXCHECK
772 # if HAVE_RAW_DECL_WCSNCASECMP
773 _GL_WARN_ON_USE (wcsncasecmp
, "wcsncasecmp is unportable - "
774 "use gnulib module wcsncasecmp for portability");
779 /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
780 category of the current locale. */
783 _GL_FUNCDECL_SYS (wcscoll
, int, (const wchar_t *s1
, const wchar_t *s2
));
785 _GL_CXXALIAS_SYS (wcscoll
, int, (const wchar_t *s1
, const wchar_t *s2
));
786 _GL_CXXALIASWARN (wcscoll
);
787 #elif defined GNULIB_POSIXCHECK
789 # if HAVE_RAW_DECL_WCSCOLL
790 _GL_WARN_ON_USE (wcscoll
, "wcscoll is unportable - "
791 "use gnulib module wcscoll for portability");
796 /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
797 to two transformed strings the result is the as applying 'wcscoll' to the
801 _GL_FUNCDECL_SYS (wcsxfrm
, size_t, (wchar_t *s1
, const wchar_t *s2
, size_t n
));
803 _GL_CXXALIAS_SYS (wcsxfrm
, size_t, (wchar_t *s1
, const wchar_t *s2
, size_t n
));
804 _GL_CXXALIASWARN (wcsxfrm
);
805 #elif defined GNULIB_POSIXCHECK
807 # if HAVE_RAW_DECL_WCSXFRM
808 _GL_WARN_ON_USE (wcsxfrm
, "wcsxfrm is unportable - "
809 "use gnulib module wcsxfrm for portability");
814 /* Duplicate S, returning an identical malloc'd string. */
817 _GL_FUNCDECL_SYS (wcsdup
, wchar_t *, (const wchar_t *s
));
819 _GL_CXXALIAS_SYS (wcsdup
, wchar_t *, (const wchar_t *s
));
820 _GL_CXXALIASWARN (wcsdup
);
821 #elif defined GNULIB_POSIXCHECK
823 # if HAVE_RAW_DECL_WCSDUP
824 _GL_WARN_ON_USE (wcsdup
, "wcsdup is unportable - "
825 "use gnulib module wcsdup for portability");
830 /* Find the first occurrence of WC in WCS. */
833 _GL_FUNCDECL_SYS (wcschr
, wchar_t *, (const wchar_t *wcs
, wchar_t wc
)
836 /* On some systems, this function is defined as an overloaded function:
838 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
839 wchar_t * std::wcschr (wchar_t *, wchar_t);
841 _GL_CXXALIAS_SYS_CAST2 (wcschr
,
842 wchar_t *, (const wchar_t *, wchar_t),
843 const wchar_t *, (const wchar_t *, wchar_t));
844 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
845 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
846 _GL_CXXALIASWARN1 (wcschr
, wchar_t *, (wchar_t *wcs
, wchar_t wc
));
847 _GL_CXXALIASWARN1 (wcschr
, const wchar_t *, (const wchar_t *wcs
, wchar_t wc
));
849 _GL_CXXALIASWARN (wcschr
);
851 #elif defined GNULIB_POSIXCHECK
853 # if HAVE_RAW_DECL_WCSCHR
854 _GL_WARN_ON_USE (wcschr
, "wcschr is unportable - "
855 "use gnulib module wcschr for portability");
860 /* Find the last occurrence of WC in WCS. */
863 _GL_FUNCDECL_SYS (wcsrchr
, wchar_t *, (const wchar_t *wcs
, wchar_t wc
)
866 /* On some systems, this function is defined as an overloaded function:
868 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
869 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
871 _GL_CXXALIAS_SYS_CAST2 (wcsrchr
,
872 wchar_t *, (const wchar_t *, wchar_t),
873 const wchar_t *, (const wchar_t *, wchar_t));
874 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
875 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
876 _GL_CXXALIASWARN1 (wcsrchr
, wchar_t *, (wchar_t *wcs
, wchar_t wc
));
877 _GL_CXXALIASWARN1 (wcsrchr
, const wchar_t *, (const wchar_t *wcs
, wchar_t wc
));
879 _GL_CXXALIASWARN (wcsrchr
);
881 #elif defined GNULIB_POSIXCHECK
883 # if HAVE_RAW_DECL_WCSRCHR
884 _GL_WARN_ON_USE (wcsrchr
, "wcsrchr is unportable - "
885 "use gnulib module wcsrchr for portability");
890 /* Return the length of the initial segmet of WCS which consists entirely
891 of wide characters not in REJECT. */
894 _GL_FUNCDECL_SYS (wcscspn
, size_t, (const wchar_t *wcs
, const wchar_t *reject
)
897 _GL_CXXALIAS_SYS (wcscspn
, size_t, (const wchar_t *wcs
, const wchar_t *reject
));
898 _GL_CXXALIASWARN (wcscspn
);
899 #elif defined GNULIB_POSIXCHECK
901 # if HAVE_RAW_DECL_WCSCSPN
902 _GL_WARN_ON_USE (wcscspn
, "wcscspn is unportable - "
903 "use gnulib module wcscspn for portability");
908 /* Return the length of the initial segmet of WCS which consists entirely
909 of wide characters in ACCEPT. */
912 _GL_FUNCDECL_SYS (wcsspn
, size_t, (const wchar_t *wcs
, const wchar_t *accept
)
915 _GL_CXXALIAS_SYS (wcsspn
, size_t, (const wchar_t *wcs
, const wchar_t *accept
));
916 _GL_CXXALIASWARN (wcsspn
);
917 #elif defined GNULIB_POSIXCHECK
919 # if HAVE_RAW_DECL_WCSSPN
920 _GL_WARN_ON_USE (wcsspn
, "wcsspn is unportable - "
921 "use gnulib module wcsspn for portability");
926 /* Find the first occurrence in WCS of any character in ACCEPT. */
929 _GL_FUNCDECL_SYS (wcspbrk
, wchar_t *,
930 (const wchar_t *wcs
, const wchar_t *accept
)
933 /* On some systems, this function is defined as an overloaded function:
935 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
936 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
938 _GL_CXXALIAS_SYS_CAST2 (wcspbrk
,
939 wchar_t *, (const wchar_t *, const wchar_t *),
940 const wchar_t *, (const wchar_t *, const wchar_t *));
941 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
942 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
943 _GL_CXXALIASWARN1 (wcspbrk
, wchar_t *,
944 (wchar_t *wcs
, const wchar_t *accept
));
945 _GL_CXXALIASWARN1 (wcspbrk
, const wchar_t *,
946 (const wchar_t *wcs
, const wchar_t *accept
));
948 _GL_CXXALIASWARN (wcspbrk
);
950 #elif defined GNULIB_POSIXCHECK
952 # if HAVE_RAW_DECL_WCSPBRK
953 _GL_WARN_ON_USE (wcspbrk
, "wcspbrk is unportable - "
954 "use gnulib module wcspbrk for portability");
959 /* Find the first occurrence of NEEDLE in HAYSTACK. */
962 _GL_FUNCDECL_SYS (wcsstr
, wchar_t *,
963 (const wchar_t *haystack
, const wchar_t *needle
)
966 /* On some systems, this function is defined as an overloaded function:
968 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
969 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
971 _GL_CXXALIAS_SYS_CAST2 (wcsstr
,
972 wchar_t *, (const wchar_t *, const wchar_t *),
973 const wchar_t *, (const wchar_t *, const wchar_t *));
974 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
975 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
976 _GL_CXXALIASWARN1 (wcsstr
, wchar_t *,
977 (wchar_t *haystack
, const wchar_t *needle
));
978 _GL_CXXALIASWARN1 (wcsstr
, const wchar_t *,
979 (const wchar_t *haystack
, const wchar_t *needle
));
981 _GL_CXXALIASWARN (wcsstr
);
983 #elif defined GNULIB_POSIXCHECK
985 # if HAVE_RAW_DECL_WCSSTR
986 _GL_WARN_ON_USE (wcsstr
, "wcsstr is unportable - "
987 "use gnulib module wcsstr for portability");
992 /* Divide WCS into tokens separated by characters in DELIM. */
995 _GL_FUNCDECL_SYS (wcstok
, wchar_t *,
996 (wchar_t *wcs
, const wchar_t *delim
, wchar_t **ptr
));
998 _GL_CXXALIAS_SYS (wcstok
, wchar_t *,
999 (wchar_t *wcs
, const wchar_t *delim
, wchar_t **ptr
));
1000 _GL_CXXALIASWARN (wcstok
);
1001 #elif defined GNULIB_POSIXCHECK
1003 # if HAVE_RAW_DECL_WCSTOK
1004 _GL_WARN_ON_USE (wcstok
, "wcstok is unportable - "
1005 "use gnulib module wcstok for portability");
1010 /* Determine number of column positions required for first N wide
1011 characters (or fewer if S ends before this) in S. */
1012 #if @GNULIB_WCSWIDTH@
1013 # if @REPLACE_WCSWIDTH@
1014 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1016 # define wcswidth rpl_wcswidth
1018 _GL_FUNCDECL_RPL (wcswidth
, int, (const wchar_t *s
, size_t n
)
1019 _GL_ATTRIBUTE_PURE
);
1020 _GL_CXXALIAS_RPL (wcswidth
, int, (const wchar_t *s
, size_t n
));
1022 # if !@HAVE_WCSWIDTH@
1023 _GL_FUNCDECL_SYS (wcswidth
, int, (const wchar_t *s
, size_t n
)
1024 _GL_ATTRIBUTE_PURE
);
1026 _GL_CXXALIAS_SYS (wcswidth
, int, (const wchar_t *s
, size_t n
));
1028 _GL_CXXALIASWARN (wcswidth
);
1029 #elif defined GNULIB_POSIXCHECK
1031 # if HAVE_RAW_DECL_WCSWIDTH
1032 _GL_WARN_ON_USE (wcswidth
, "wcswidth is unportable - "
1033 "use gnulib module wcswidth for portability");
1038 /* Convert *TP to a date and time wide string. See
1039 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
1040 #if @GNULIB_WCSFTIME@
1041 # if @REPLACE_WCSFTIME@
1042 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1044 # define wcsftime rpl_wcsftime
1046 _GL_FUNCDECL_RPL (wcsftime
, size_t, (wchar_t *__buf
, size_t __bufsize
,
1047 const wchar_t *__fmt
, const struct tm
*__tp
)
1048 _GL_ARG_NONNULL ((1, 3, 4)));
1049 _GL_CXXALIAS_RPL (wcsftime
, size_t, (wchar_t *__buf
, size_t __bufsize
,
1050 const wchar_t *__fmt
, const struct tm
*__tp
));
1052 # if !@HAVE_WCSFTIME@
1053 _GL_FUNCDECL_SYS (wcsftime
, size_t, (wchar_t *__buf
, size_t __bufsize
,
1054 const wchar_t *__fmt
, const struct tm
*__tp
)
1055 _GL_ARG_NONNULL ((1, 3, 4)));
1057 _GL_CXXALIAS_SYS (wcsftime
, size_t, (wchar_t *__buf
, size_t __bufsize
,
1058 const wchar_t *__fmt
, const struct tm
*__tp
));
1060 _GL_CXXALIASWARN (wcsftime
);
1061 #elif defined GNULIB_POSIXCHECK
1063 # if HAVE_RAW_DECL_WCSFTIME
1064 _GL_WARN_ON_USE (wcsftime
, "wcsftime is unportable - "
1065 "use gnulib module wcsftime for portability");
1070 #endif /* _@GUARD_PREFIX@_WCHAR_H */
1071 #endif /* _@GUARD_PREFIX@_WCHAR_H */