summaryrefslogtreecommitdiff
path: root/lib/wchar.in.h
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2025-10-18 19:06:52 +0200
committerJörg Frings-Fürst <debian@jff.email>2025-10-18 19:06:52 +0200
commit27dae84ed92f1ef0300263091972338d12e78348 (patch)
tree7c52931f474fafb8a4bd4fd15ca3461c77cdecc2 /lib/wchar.in.h
parent4682deeb62247d34de87f8e777f99e2d337fd377 (diff)
New upstream version 1.4.1upstream/1.4.1upstream
Diffstat (limited to 'lib/wchar.in.h')
-rw-r--r--lib/wchar.in.h166
1 files changed, 126 insertions, 40 deletions
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index 54354559..ab602a28 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-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 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
@@ -36,8 +36,7 @@
&& ((defined _INTTYPES_INCLUDED \
&& !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \
|| defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
- || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
- || defined _GL_ALREADY_INCLUDING_WCHAR_H)
+ || (defined __MINGW32__ && defined __STRING_H_SOURCED__))
/* Special invocation convention:
- Inside glibc and uClibc header files, but not MinGW.
- On HP-UX 11.00 we have a sequence of nested includes
@@ -47,20 +46,18 @@
therefore we cannot provide the function overrides; instead include only
the system's <wchar.h>.
- With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of
- <wchar.h> is actually processed, and that doesn't include 'mbstate_t'.
- - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
- the latter includes <wchar.h>. But here, we have no way to detect whether
- <wctype.h> is completely included or is still being included. */
+ <wchar.h> is actually processed, and that doesn't include 'mbstate_t'. */
#@INCLUDE_NEXT@ @NEXT_WCHAR_H@
+/* The glibc 2.5 /usr/include/wchar.h defines __need_wint_t but never undefines
+ it. We need to do that here. */
+#undef __need_wint_t
#else
/* Normal invocation convention. */
#ifndef _@GUARD_PREFIX@_WCHAR_H
-#define _GL_ALREADY_INCLUDING_WCHAR_H
-
#if @HAVE_FEATURES_H@
# include <features.h> /* for __GLIBC__ */
#endif
@@ -79,8 +76,6 @@
# @INCLUDE_NEXT@ @NEXT_WCHAR_H@
#endif
-#undef _GL_ALREADY_INCLUDING_WCHAR_H
-
#ifndef _@GUARD_PREFIX@_WCHAR_H
#define _@GUARD_PREFIX@_WCHAR_H
@@ -107,7 +102,7 @@
/* Applies to: functions. Cannot be used on inline functions. */
#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
# if defined __cplusplus && defined __GNUC__ && !defined __clang__
-/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
+/* Work around GCC bug <https://gcc.gnu.org/PR108231> */
# define _GL_ATTRIBUTE_DEALLOC_FREE \
_GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
# else
@@ -137,6 +132,18 @@
# endif
#endif
+/* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP
+ (a pointer) must not be NULL if the argument NI (an integer) is != 0. */
+/* Applies to: functions. */
+#ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO
+# if __GNUC__ >= 15 && !defined __clang__
+# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) \
+ __attribute__ ((__nonnull_if_nonzero__ (np, ni)))
+# else
+# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni)
+# endif
+#endif
+
/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
*/
#ifndef _GL_ATTRIBUTE_NOTHROW
@@ -196,17 +203,11 @@ typedef unsigned int rpl_wint_t;
/* Override mbstate_t if it is too small.
- On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
- implementing mbrtowc for encodings like UTF-8.
- On AIX and MSVC, mbrtowc needs to be overridden, but mbstate_t exists and is
- large enough and overriding it would cause problems in C++ mode. */
+ On AIX, MSVC, and OpenBSD 6.0, mbrtowc needs to be overridden, but
+ mbstate_t exists and is large enough and overriding it would cause problems
+ in C++ mode. */
#if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
# if !GNULIB_defined_mbstate_t
-# if !(defined _AIX || defined _MSC_VER)
-typedef int rpl_mbstate_t;
-# undef mbstate_t
-# define mbstate_t rpl_mbstate_t
-# endif
# define GNULIB_defined_mbstate_t 1
# endif
#endif
@@ -262,6 +263,55 @@ _GL_EXTERN_C void free (void *);
#endif
+/* Declarations for ISO C N3322. */
+#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
+_GL_EXTERN_C wchar_t *wmemcpy (wchar_t *__dest, const wchar_t *__src, size_t __n)
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+ _GL_ATTRIBUTE_NOTHROW
+# endif
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+_GL_EXTERN_C wchar_t *wmemmove (wchar_t *__dest, const wchar_t *__src, size_t __n)
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+ _GL_ATTRIBUTE_NOTHROW
+# endif
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+_GL_EXTERN_C wchar_t *wcsncpy (wchar_t *__dest, const wchar_t *__src, size_t __n)
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+ _GL_ATTRIBUTE_NOTHROW
+# endif
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+_GL_EXTERN_C wchar_t *wcsncat (wchar_t *__dest, const wchar_t *__src, size_t __n)
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+ _GL_ATTRIBUTE_NOTHROW
+# endif
+ _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+_GL_EXTERN_C int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+ _GL_ATTRIBUTE_NOTHROW
+# endif
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+_GL_EXTERN_C int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+ _GL_ATTRIBUTE_NOTHROW
+# endif
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+# ifndef __cplusplus
+_GL_EXTERN_C wchar_t *wmemchr (const wchar_t *__s, wchar_t __wc, size_t __n)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
+# endif
+_GL_EXTERN_C wchar_t *wmemset (wchar_t *__s, wchar_t __wc, size_t __n)
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+ _GL_ATTRIBUTE_NOTHROW
+# endif
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
+#endif
+
+
/* Convert a single-byte character to a wide character. */
#if @GNULIB_BTOWC@
# if @REPLACE_BTOWC@
@@ -300,8 +350,8 @@ _GL_WARN_ON_USE (btowc, "btowc is unportable - "
_GL_FUNCDECL_RPL (wctob, int, (wint_t wc), _GL_ATTRIBUTE_PURE);
_GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
# else
-# if !defined wctob && !@HAVE_DECL_WCTOB@
-/* wctob is provided by gnulib, or wctob exists but is not declared. */
+# if !defined wctob && !@HAVE_WCTOB@
+/* wctob is provided by gnulib. */
_GL_FUNCDECL_SYS (wctob, int, (wint_t wc), _GL_ATTRIBUTE_PURE);
# endif
_GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
@@ -378,7 +428,7 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
without considering what mbsinit() does, we get test failures such as
assertion "mbsinit (&iter->state)" failed
*/
-# if GNULIB_defined_mbstate_t /* AIX, IRIX */
+# if GNULIB_defined_mbstate_t /* AIX */
/* mbstate_t has at least 4 bytes. They are used as coded in
gnulib/lib/mbrtowc.c. */
# define _GL_MBSTATE_INIT_SIZE 1
@@ -531,16 +581,19 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
# define _GL_MBSTATE_ZERO_SIZE sizeof (mbstate_t)
# endif
_GL_BEGIN_C_LINKAGE
-# if defined IN_MBSZERO
+# if !GNULIB_defined_mbszero
+# if defined IN_MBSZERO
_GL_EXTERN_INLINE
-# else
+# else
_GL_INLINE
-# endif
+# endif
_GL_ARG_NONNULL ((1)) void
mbszero (mbstate_t *ps)
{
memset (ps, 0, _GL_MBSTATE_ZERO_SIZE);
}
+# define GNULIB_defined_mbszero 1
+# endif
_GL_END_C_LINKAGE
_GL_CXXALIAS_SYS (mbszero, void, (mbstate_t *ps));
_GL_CXXALIASWARN (mbszero);
@@ -843,8 +896,9 @@ _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
/* Search N wide characters of S for C. */
#if @GNULIB_WMEMCHR@
# if !@HAVE_WMEMCHR@
-_GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n),
- _GL_ATTRIBUTE_PURE);
+_GL_FUNCDECL_SYS (wmemchr, wchar_t *,
+ (const wchar_t *s, wchar_t c, size_t n),
+ _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
# endif
/* On some systems, this function is defined as an overloaded function:
extern "C++" {
@@ -881,14 +935,18 @@ _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
# endif
_GL_FUNCDECL_RPL (wmemcmp, int,
(const wchar_t *s1, const wchar_t *s2, size_t n),
- _GL_ATTRIBUTE_PURE);
+ _GL_ATTRIBUTE_PURE
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
_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);
+ _GL_ATTRIBUTE_PURE
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
# endif
_GL_CXXALIAS_SYS (wmemcmp, int,
(const wchar_t *s1, const wchar_t *s2, size_t n));
@@ -910,7 +968,9 @@ _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
# if !@HAVE_WMEMCPY@
_GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
(wchar_t *restrict dest,
- const wchar_t *restrict src, size_t n), );
+ const wchar_t *restrict src, size_t n),
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
# endif
_GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
(wchar_t *restrict dest,
@@ -932,7 +992,9 @@ _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
#if @GNULIB_WMEMMOVE@
# if !@HAVE_WMEMMOVE@
_GL_FUNCDECL_SYS (wmemmove, wchar_t *,
- (wchar_t *dest, const wchar_t *src, size_t n), );
+ (wchar_t *dest, const wchar_t *src, size_t n),
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
# endif
_GL_CXXALIAS_SYS (wmemmove, wchar_t *,
(wchar_t *dest, const wchar_t *src, size_t n));
@@ -987,7 +1049,8 @@ _GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
/* Set N wide characters of S to C. */
#if @GNULIB_WMEMSET@
# if !@HAVE_WMEMSET@
-_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n), );
+_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n),
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
# endif
_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
# if __GLIBC__ >= 2
@@ -1086,7 +1149,9 @@ _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
# if !@HAVE_WCSNCPY@
_GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
(wchar_t *restrict dest,
- const wchar_t *restrict src, size_t n), );
+ const wchar_t *restrict src, size_t n),
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
# endif
_GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
(wchar_t *restrict dest,
@@ -1149,14 +1214,31 @@ _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
/* Append no more than N wide characters of SRC onto DEST. */
#if @GNULIB_WCSNCAT@
-# if !@HAVE_WCSNCAT@
+# if @REPLACE_WCSNCAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcsncat
+# define wcsncat rpl_wcsncat
+# endif
+_GL_FUNCDECL_RPL (wcsncat, wchar_t *,
+ (wchar_t *restrict dest, const wchar_t *restrict src,
+ size_t n),
+ _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
+_GL_CXXALIAS_RPL (wcsncat, wchar_t *,
+ (wchar_t *restrict dest, const wchar_t *restrict src,
+ size_t n));
+# else
+# if !@HAVE_WCSNCAT@
_GL_FUNCDECL_SYS (wcsncat, wchar_t *,
(wchar_t *restrict dest, const wchar_t *restrict src,
- size_t n), );
-# endif
+ size_t n),
+ _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
+# endif
_GL_CXXALIAS_SYS (wcsncat, wchar_t *,
(wchar_t *restrict dest, const wchar_t *restrict src,
size_t n));
+# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (wcsncat);
# endif
@@ -1207,14 +1289,18 @@ _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
# endif
_GL_FUNCDECL_RPL (wcsncmp, int,
(const wchar_t *s1, const wchar_t *s2, size_t n),
- _GL_ATTRIBUTE_PURE);
+ _GL_ATTRIBUTE_PURE
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
_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);
+ _GL_ATTRIBUTE_PURE
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
# endif
_GL_CXXALIAS_SYS (wcsncmp, int,
(const wchar_t *s1, const wchar_t *s2, size_t n));