summaryrefslogtreecommitdiff
path: root/lib/wchar.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/wchar.in.h')
-rw-r--r--lib/wchar.in.h385
1 files changed, 368 insertions, 17 deletions
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index 3558adfb..a33a10f7 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -1,6 +1,6 @@
/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
- Copyright (C) 2007-2022 Free Software Foundation, Inc.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -84,6 +84,13 @@
#ifndef _@GUARD_PREFIX@_WCHAR_H
#define _@GUARD_PREFIX@_WCHAR_H
+/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
+ _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
+ HAVE_RAW_DECL_*. */
+#if !_GL_CONFIG_H_INCLUDED
+ #error "Please include config.h first."
+#endif
+
/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
that can be freed by passing them as the Ith argument to the
function F. */
@@ -99,7 +106,14 @@
can be freed via 'free'; it can be used only after declaring 'free'. */
/* Applies to: functions. Cannot be used on inline functions. */
#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
-# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
+# if defined __cplusplus && defined __GNUC__ && !defined __clang__
+/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
+# define _GL_ATTRIBUTE_DEALLOC_FREE \
+ _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
+# else
+# define _GL_ATTRIBUTE_DEALLOC_FREE \
+ _GL_ATTRIBUTE_DEALLOC (free, 1)
+# endif
#endif
/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
@@ -123,6 +137,28 @@
# endif
#endif
+/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
+ */
+#ifndef _GL_ATTRIBUTE_NOTHROW
+# if defined __cplusplus
+# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
+# if __cplusplus >= 201103L
+# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
+# else
+# define _GL_ATTRIBUTE_NOTHROW throw ()
+# endif
+# else
+# define _GL_ATTRIBUTE_NOTHROW
+# endif
+# else
+# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
+# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
+# else
+# define _GL_ATTRIBUTE_NOTHROW
+# endif
+# endif
+#endif
+
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -181,7 +217,11 @@ typedef int rpl_mbstate_t;
# if (@REPLACE_FREE@ && !defined free \
&& !(defined __cplusplus && defined GNULIB_NAMESPACE))
/* We can't do '#define free rpl_free' here. */
+# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW;
+# else
_GL_EXTERN_C void rpl_free (void *);
+# endif
# undef _GL_ATTRIBUTE_DEALLOC_FREE
# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
# else
@@ -193,7 +233,7 @@ _GL_EXTERN_C
void __cdecl free (void *);
# else
# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
-_GL_EXTERN_C void free (void *) throw ();
+_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
# else
_GL_EXTERN_C void free (void *);
# endif
@@ -208,13 +248,20 @@ _GL_EXTERN_C
void __cdecl free (void *);
# else
# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
-_GL_EXTERN_C void free (void *) throw ();
+_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
# else
_GL_EXTERN_C void free (void *);
# endif
# endif
#endif
+
+#if @GNULIB_MBSZERO@
+/* Get memset(). */
+# include <string.h>
+#endif
+
+
/* Convert a single-byte character to a wide character. */
#if @GNULIB_BTOWC@
# if @REPLACE_BTOWC@
@@ -271,7 +318,7 @@ _GL_WARN_ON_USE (wctob, "wctob is unportable - "
#endif
-/* Test whether *PS is in the initial state. */
+/* Test whether *PS is in an initial state. */
#if @GNULIB_MBSINIT@
# if @REPLACE_MBSINIT@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -298,6 +345,208 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
#endif
+/* Put *PS into an initial state. */
+#if @GNULIB_MBSZERO@
+/* ISO C 23 ยง 7.31.6.(3) says that zeroing an mbstate_t is a way to put the
+ mbstate_t into an initial state. However, on many platforms an mbstate_t
+ is large, and it is possible - as an optimization - to get away with zeroing
+ only part of it. So, instead of
+
+ mbstate_t state = { 0 };
+
+ or
+
+ mbstate_t state;
+ memset (&state, 0, sizeof (mbstate_t));
+
+ we can write this faster code:
+
+ mbstate_t state;
+ mbszero (&state);
+ */
+/* _GL_MBSTATE_INIT_SIZE describes how mbsinit() behaves: It is the number of
+ bytes at the beginning of an mbstate_t that need to be zero, for mbsinit()
+ to return true.
+ _GL_MBSTATE_ZERO_SIZE is the number of bytes at the beginning of an mbstate_t
+ that need to be zero,
+ - for mbsinit() to return true, and
+ - for all other multibyte-aware functions to operate properly.
+ 0 < _GL_MBSTATE_INIT_SIZE <= _GL_MBSTATE_ZERO_SIZE <= sizeof (mbstate_t).
+ These values are determined by source code inspection, where possible, and
+ by running the gnulib unit tests.
+ We need _GL_MBSTATE_INIT_SIZE because if we define _GL_MBSTATE_ZERO_SIZE
+ without considering what mbsinit() does, we get test failures such as
+ assertion "mbsinit (&iter->state)" failed
+ */
+# if GNULIB_defined_mbstate_t /* AIX, IRIX */
+/* mbstate_t has at least 4 bytes. They are used as coded in
+ gnulib/lib/mbrtowc.c. */
+# define _GL_MBSTATE_INIT_SIZE 1
+/* define _GL_MBSTATE_ZERO_SIZE 4
+ does not work: it causes test failures.
+ So, use the safe fallback value, below. */
+# elif __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 /* glibc */
+/* mbstate_t is defined in <bits/types/__mbstate_t.h>.
+ For more details, see glibc/iconv/skeleton.c. */
+# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (((mbstate_t) {0}).__count) */
+# define _GL_MBSTATE_ZERO_SIZE /* 8 */ sizeof (mbstate_t)
+# elif defined MUSL_LIBC /* musl libc */
+/* mbstate_t is defined in <bits/alltypes.h>.
+ It is an opaque aligned 8-byte struct, of which at most the first
+ 4 bytes are used.
+ For more details, see src/multibyte/mbrtowc.c. */
+# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (unsigned) */
+# define _GL_MBSTATE_ZERO_SIZE 4
+# elif defined __APPLE__ && defined __MACH__ /* macOS */
+/* On macOS, mbstate_t is defined in <machine/_types.h>.
+ It is an opaque aligned 128-byte struct, of which at most the first
+ 12 bytes are used.
+ For more details, see the __mbsinit implementations in
+ Libc-<version>/locale/FreeBSD/
+ {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8,utf2}.c. */
+/* File INIT_SIZE ZERO_SIZE
+ ascii.c 0 0
+ none.c 0 0
+ euc.c 12 12
+ mskanji.c 4 4
+ big5.c 4 4
+ gb2312.c 4 6
+ gbk.c 4 4
+ gb18030.c 4 8
+ utf8.c 8 10
+ utf2.c 8 12 */
+# define _GL_MBSTATE_INIT_SIZE 12
+# define _GL_MBSTATE_ZERO_SIZE 12
+# elif defined __FreeBSD__ /* FreeBSD */
+/* On FreeBSD, mbstate_t is defined in src/sys/sys/_types.h.
+ It is an opaque aligned 128-byte struct, of which at most the first
+ 12 bytes are used.
+ For more details, see the __mbsinit implementations in
+ src/lib/libc/locale/
+ {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
+/* File INIT_SIZE ZERO_SIZE
+ ascii.c 0 0
+ none.c 0 0
+ euc.c 12 12
+ mskanji.c 4 4
+ big5.c 4 4
+ gb2312.c 4 6
+ gbk.c 4 4
+ gb18030.c 4 8
+ utf8.c 8 12 */
+# define _GL_MBSTATE_INIT_SIZE 12
+# define _GL_MBSTATE_ZERO_SIZE 12
+# elif defined __NetBSD__ /* NetBSD */
+/* On NetBSD, mbstate_t is defined in src/sys/sys/ansi.h.
+ It is an opaque aligned 128-byte struct, of which at most the first
+ 28 bytes are used.
+ For more details, see the *State types in
+ src/lib/libc/citrus/modules/citrus_*.c
+ (ignoring citrus_{hz,iso2022,utf7,viqr,zw}.c, since these implement
+ stateful encodings, not usable as locale encodings). */
+/* File ZERO_SIZE
+ citrus/citrus_none.c 0
+ citrus/modules/citrus_euc.c 8
+ citrus/modules/citrus_euctw.c 8
+ citrus/modules/citrus_mskanji.c 8
+ citrus/modules/citrus_big5.c 8
+ citrus/modules/citrus_gbk2k.c 8
+ citrus/modules/citrus_dechanyu.c 8
+ citrus/modules/citrus_johab.c 6
+ citrus/modules/citrus_utf8.c 12 */
+/* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
+ failures for values < 28. */
+# define _GL_MBSTATE_ZERO_SIZE 28
+# elif defined __OpenBSD__ /* OpenBSD */
+/* On OpenBSD, mbstate_t is defined in src/sys/sys/_types.h.
+ It is an opaque aligned 128-byte struct, of which at most the first
+ 12 bytes are used.
+ For more details, see src/lib/libc/citrus/citrus_*.c. */
+/* File INIT_SIZE ZERO_SIZE
+ citrus_none.c 0 0
+ citrus_utf8.c 12 12 */
+# define _GL_MBSTATE_INIT_SIZE 12
+# define _GL_MBSTATE_ZERO_SIZE 12
+# elif defined __minix /* Minix */
+/* On Minix, mbstate_t is defined in sys/sys/ansi.h.
+ It is an opaque aligned 128-byte struct.
+ For more details, see the *State types in
+ lib/libc/citrus/citrus_*.c. */
+/* File INIT_SIZE ZERO_SIZE
+ citrus_none.c 0 0 */
+/* But 1 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
+ failures for values < 4. */
+# define _GL_MBSTATE_ZERO_SIZE 4
+# elif defined __sun /* Solaris */
+/* On Solaris, mbstate_t is defined in <wchar_impl.h>.
+ It is an opaque aligned 24-byte or 32-byte struct, of which at most the first
+ 20 or 28 bytes are used.
+ For more details on OpenSolaris derivatives, see the *State types in
+ illumos-gate/usr/src/lib/libc/port/locale/
+ {none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
+/* File INIT_SIZE ZERO_SIZE
+ none.c 0 0
+ euc.c 12 12
+ mskanji.c 4 4
+ big5.c 4 4
+ gb2312.c 4 6
+ gbk.c 4 4
+ gb18030.c 4 8
+ utf8.c 12 12 */
+/* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
+ failures
+ - in OpenIndiana and OmniOS: for values < 16,
+ - in Solaris 10 and 11: for values < 20 (in 32-bit mode)
+ or < 28 (in 64-bit mode).
+ Since we don't have a good way to distinguish the OpenSolaris derivatives
+ from the proprietary Solaris versions, and can't inspect the Solaris source
+ code, use the safe fallback values, below. */
+# elif defined __CYGWIN__ /* Cygwin */
+/* On Cygwin, mbstate_t is defined in <sys/_types.h>.
+ For more details, see newlib/libc/stdlib/mbtowc_r.c and
+ winsup/cygwin/strfuncs.cc. */
+# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (int) */
+# define _GL_MBSTATE_ZERO_SIZE 8
+# elif defined _WIN32 && !defined __CYGWIN__ /* Native Windows. */
+/* MSVC defines 'mbstate_t' as an aligned 8-byte struct.
+ On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined
+ as an aligned 8-byte struct, of which the first 4 bytes matter.
+ Use the safe values, below. */
+# elif defined __ANDROID__ /* Android */
+/* Android defines 'mbstate_t' in <bits/mbstate_t.h>.
+ It is an opaque 4-byte or 8-byte struct.
+ For more details, see
+ bionic/libc/private/bionic_mbstate.h
+ bionic/libc/bionic/mbrtoc32.cpp
+ bionic/libc/bionic/mbrtoc16.cpp
+ */
+# define _GL_MBSTATE_INIT_SIZE 4
+# define _GL_MBSTATE_ZERO_SIZE 4
+# endif
+/* Use safe values as defaults. */
+# ifndef _GL_MBSTATE_INIT_SIZE
+# define _GL_MBSTATE_INIT_SIZE sizeof (mbstate_t)
+# endif
+# ifndef _GL_MBSTATE_ZERO_SIZE
+# define _GL_MBSTATE_ZERO_SIZE sizeof (mbstate_t)
+# endif
+_GL_BEGIN_C_LINKAGE
+# if defined IN_MBSZERO
+_GL_EXTERN_INLINE
+# else
+_GL_INLINE
+# endif
+_GL_ARG_NONNULL ((1)) void
+mbszero (mbstate_t *ps)
+{
+ memset (ps, 0, _GL_MBSTATE_ZERO_SIZE);
+}
+_GL_END_C_LINKAGE
+_GL_CXXALIAS_SYS (mbszero, void, (mbstate_t *ps));
+_GL_CXXALIASWARN (mbszero);
+#endif
+
+
/* Convert a multibyte character to a wide character. */
#if @GNULIB_MBRTOWC@
# if @REPLACE_MBRTOWC@
@@ -434,7 +683,9 @@ _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
const char **restrict srcp, size_t srclen, size_t len,
mbstate_t *restrict ps));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (mbsnrtowcs);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef mbsnrtowcs
# if HAVE_RAW_DECL_MBSNRTOWCS
@@ -622,13 +873,25 @@ _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
/* Compare N wide characters of S1 and S2. */
#if @GNULIB_WMEMCMP@
-# if !@HAVE_WMEMCMP@
+# if @REPLACE_WMEMCMP@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wmemcmp
+# define wmemcmp rpl_wmemcmp
+# endif
+_GL_FUNCDECL_RPL (wmemcmp, int,
+ (const wchar_t *s1, const wchar_t *s2, size_t n)
+ _GL_ATTRIBUTE_PURE);
+_GL_CXXALIAS_RPL (wmemcmp, int,
+ (const wchar_t *s1, const wchar_t *s2, size_t n));
+# else
+# if !@HAVE_WMEMCMP@
_GL_FUNCDECL_SYS (wmemcmp, int,
(const wchar_t *s1, const wchar_t *s2, size_t n)
_GL_ATTRIBUTE_PURE);
-# endif
+# endif
_GL_CXXALIAS_SYS (wmemcmp, int,
(const wchar_t *s1, const wchar_t *s2, size_t n));
+# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (wmemcmp);
# endif
@@ -687,14 +950,27 @@ _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
/* Copy N wide characters of SRC to DEST.
Return pointer to wide characters after the last written wide character. */
#if @GNULIB_WMEMPCPY@
-# if !@HAVE_WMEMPCPY@
+# if @REPLACE_WMEMPCPY@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wmempcpy
+# define wmempcpy rpl_wmempcpy
+# endif
+_GL_FUNCDECL_RPL (wmempcpy, wchar_t *,
+ (wchar_t *restrict dest,
+ const wchar_t *restrict src, size_t n));
+_GL_CXXALIAS_RPL (wmempcpy, wchar_t *,
+ (wchar_t *restrict dest,
+ const wchar_t *restrict src, size_t n));
+# else
+# if !@HAVE_WMEMPCPY@
_GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
(wchar_t *restrict dest,
const wchar_t *restrict src, size_t n));
-# endif
+# endif
_GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
(wchar_t *restrict dest,
const wchar_t *restrict src, size_t n));
+# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (wmempcpy);
# endif
@@ -894,11 +1170,21 @@ _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
/* Compare S1 and S2. */
#if @GNULIB_WCSCMP@
-# if !@HAVE_WCSCMP@
+# if @REPLACE_WCSCMP@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcscmp
+# define wcscmp rpl_wcscmp
+# endif
+_GL_FUNCDECL_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)
+ _GL_ATTRIBUTE_PURE);
+_GL_CXXALIAS_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
+# else
+# if !@HAVE_WCSCMP@
_GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)
_GL_ATTRIBUTE_PURE);
-# endif
+# endif
_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
+# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (wcscmp);
# endif
@@ -913,13 +1199,25 @@ _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
/* Compare no more than N wide characters of S1 and S2. */
#if @GNULIB_WCSNCMP@
-# if !@HAVE_WCSNCMP@
+# if @REPLACE_WCSNCMP@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcsncmp
+# define wcsncmp rpl_wcsncmp
+# endif
+_GL_FUNCDECL_RPL (wcsncmp, int,
+ (const wchar_t *s1, const wchar_t *s2, size_t n)
+ _GL_ATTRIBUTE_PURE);
+_GL_CXXALIAS_RPL (wcsncmp, int,
+ (const wchar_t *s1, const wchar_t *s2, size_t n));
+# else
+# if !@HAVE_WCSNCMP@
_GL_FUNCDECL_SYS (wcsncmp, int,
(const wchar_t *s1, const wchar_t *s2, size_t n)
_GL_ATTRIBUTE_PURE);
-# endif
+# endif
_GL_CXXALIAS_SYS (wcsncmp, int,
(const wchar_t *s1, const wchar_t *s2, size_t n));
+# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (wcsncmp);
# endif
@@ -1028,9 +1326,16 @@ _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
namespace, not in the global namespace. So, force a declaration in
the global namespace. */
# if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
(const wchar_t *s)
+ _GL_ATTRIBUTE_NOTHROW
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
+# else
+_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
+ (const wchar_t *s)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
+# endif
# endif
_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
# endif
@@ -1038,9 +1343,16 @@ _GL_CXXALIASWARN (wcsdup);
#else
# if __GNUC__ >= 11 && !defined wcsdup
/* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
(const wchar_t *s)
+ _GL_ATTRIBUTE_NOTHROW
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
+# else
+_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
+ (const wchar_t *s)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
+# endif
# endif
# if defined GNULIB_POSIXCHECK
# undef wcsdup
@@ -1059,9 +1371,16 @@ _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
# endif
_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
# else
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
(const wchar_t *s)
+ _GL_ATTRIBUTE_NOTHROW
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
+# else
+_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
+ (const wchar_t *s)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
+# endif
# if @HAVE_DECL_WCSDUP@
_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
# endif
@@ -1133,7 +1452,7 @@ _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
#endif
-/* Return the length of the initial segmet of WCS which consists entirely
+/* Return the length of the initial segment of WCS which consists entirely
of wide characters not in REJECT. */
#if @GNULIB_WCSCSPN@
# if !@HAVE_WCSCSPN@
@@ -1153,7 +1472,7 @@ _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
#endif
-/* Return the length of the initial segmet of WCS which consists entirely
+/* Return the length of the initial segment of WCS which consists entirely
of wide characters in ACCEPT. */
#if @GNULIB_WCSSPN@
# if !@HAVE_WCSSPN@
@@ -1208,12 +1527,25 @@ _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
/* Find the first occurrence of NEEDLE in HAYSTACK. */
#if @GNULIB_WCSSTR@
-# if !@HAVE_WCSSTR@
+# if @REPLACE_WCSSTR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcsstr
+# define wcsstr rpl_wcsstr
+# endif
+_GL_FUNCDECL_RPL (wcsstr, wchar_t *,
+ (const wchar_t *restrict haystack,
+ const wchar_t *restrict needle)
+ _GL_ATTRIBUTE_PURE);
+_GL_CXXALIAS_RPL (wcsstr, wchar_t *,
+ (const wchar_t *restrict haystack,
+ const wchar_t *restrict needle));
+# else
+# if !@HAVE_WCSSTR@
_GL_FUNCDECL_SYS (wcsstr, wchar_t *,
(const wchar_t *restrict haystack,
const wchar_t *restrict needle)
_GL_ATTRIBUTE_PURE);
-# endif
+# endif
/* On some systems, this function is defined as an overloaded function:
extern "C++" {
const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
@@ -1224,6 +1556,7 @@ _GL_CXXALIAS_SYS_CAST2 (wcsstr,
(const wchar_t *restrict, const wchar_t *restrict),
const wchar_t *,
(const wchar_t *restrict, const wchar_t *restrict));
+# endif
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
_GL_CXXALIASWARN1 (wcsstr, wchar_t *,
@@ -1351,6 +1684,24 @@ _GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
#endif
+#if @GNULIB_WGETCWD@ && (defined _WIN32 && !defined __CYGWIN__)
+/* Gets the name of the current working directory.
+ (a) If BUF is non-NULL, it is assumed to have room for SIZE wide characters.
+ This function stores the working directory (NUL-terminated) in BUF and
+ returns BUF.
+ (b) If BUF is NULL, an array is allocated with 'malloc'. The array is SIZE
+ wide characters long, unless SIZE == 0, in which case it is as big as
+ necessary.
+ If the directory couldn't be determined or SIZE was too small, this function
+ returns NULL and sets errno. For a directory of length LEN, SIZE should be
+ >= LEN + 3 in case (a) or >= LEN + 1 in case (b).
+ Possible errno values include:
+ - ERANGE if SIZE is too small.
+ - ENOMEM if the memory could no be allocated. */
+_GL_FUNCDECL_SYS (wgetcwd, wchar_t *, (wchar_t *buf, size_t size));
+#endif
+
+
#endif /* _@GUARD_PREFIX@_WCHAR_H */
#endif /* _@GUARD_PREFIX@_WCHAR_H */
#endif