summaryrefslogtreecommitdiff
path: root/lib/string.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/string.in.h')
-rw-r--r--lib/string.in.h335
1 files changed, 319 insertions, 16 deletions
diff --git a/lib/string.in.h b/lib/string.in.h
index f5a6d8b3..fdcdd21b 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <string.h>.
- Copyright (C) 1995-1996, 2001-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-1996, 2001-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
@@ -20,7 +20,7 @@
#endif
@PRAGMA_COLUMNS@
-#if defined _GL_ALREADY_INCLUDING_STRING_H
+#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_STRING_H
/* Special invocation convention:
- On OS X/NetBSD we have a sequence of nested includes
<string.h> -> <strings.h> -> "string.h"
@@ -34,12 +34,12 @@
#ifndef _@GUARD_PREFIX@_STRING_H
-#define _GL_ALREADY_INCLUDING_STRING_H
+#define _@GUARD_PREFIX@_ALREADY_INCLUDING_STRING_H
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_STRING_H@
-#undef _GL_ALREADY_INCLUDING_STRING_H
+#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_STRING_H
#ifndef _@GUARD_PREFIX@_STRING_H
#define _@GUARD_PREFIX@_STRING_H
@@ -54,6 +54,11 @@
/* NetBSD 5.0 mis-defines NULL. */
#include <stddef.h>
+#if @GNULIB_STRERROR_L@
+/* Get locale_t. */
+# include <locale.h>
+#endif
+
/* MirBSD defines mbslen as a macro. */
#if @GNULIB_MBSLEN@ && defined __MirBSD__
# include <wchar.h>
@@ -75,6 +80,12 @@
# include <strings.h>
#endif
+_GL_INLINE_HEADER_BEGIN
+
+#ifndef _GL_STRING_INLINE
+# define _GL_STRING_INLINE _GL_INLINE
+#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. */
@@ -91,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
@@ -111,6 +122,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
@@ -149,6 +172,7 @@
/* The definition of _GL_WARN_ON_USE is copied here. */
+
/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
been included yet. */
#if @GNULIB_FREE_POSIX@
@@ -193,6 +217,91 @@ _GL_EXTERN_C void free (void *);
# endif
#endif
+
+/* Declarations for ISO C N3322. */
+#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
+# ifndef memcpy
+_GL_EXTERN_C void *memcpy (void *__dest, const void *__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);
+# endif
+# ifndef memccpy
+_GL_EXTERN_C void *memccpy (void *__dest, const void *__src, int __c, size_t __n)
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+ _GL_ATTRIBUTE_NOTHROW
+# endif
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 4)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 4);
+# endif
+# ifndef memmove
+_GL_EXTERN_C void *memmove (void *__dest, const void *__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);
+# endif
+# ifndef strncpy
+_GL_EXTERN_C char *strncpy (char *__dest, const char *__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);
+# endif
+# ifndef strndup
+_GL_EXTERN_C char *strndup (const char *__s, size_t __n)
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+ _GL_ATTRIBUTE_NOTHROW
+# endif
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2);
+# endif
+# ifndef strncat
+_GL_EXTERN_C char *strncat (char *__dest, const char *__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);
+# endif
+# ifndef memcmp
+_GL_EXTERN_C int memcmp (const void *__s1, const void *__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);
+# endif
+# ifndef strncmp
+_GL_EXTERN_C int strncmp (const char *__s1, const char *__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);
+# endif
+# if !defined memchr && !defined __cplusplus
+_GL_EXTERN_C void *memchr (const void *__s, int __c, size_t __n)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
+_GL_EXTERN_C void *memrchr (const void *__s, int __c, size_t __n)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
+# endif
+# ifndef memset
+_GL_EXTERN_C void *memset (void *__s, int __c, size_t __n)
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+ _GL_ATTRIBUTE_NOTHROW
+# endif
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
+# endif
+# ifndef memset_explicit
+_GL_EXTERN_C void *memset_explicit (void *__s, int __c, size_t __n)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
+# endif
+#endif
+
+
/* Clear a block of memory. The compiler will not delete a call to
this function, even if the block is dead after the call. */
#if @GNULIB_EXPLICIT_BZERO@
@@ -210,6 +319,7 @@ _GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
# endif
#endif
+
/* Find the index of the least-significant set bit. */
#if @GNULIB_FFSL@
# if !@HAVE_FFSL@
@@ -276,7 +386,7 @@ _GL_CXXALIASWARN (memccpy);
# endif
_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n),
_GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
# else
/* On some systems, this function is defined as an overloaded function:
@@ -305,6 +415,21 @@ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
"use gnulib module memchr for portability" );
#endif
+/* Are S1 and S2, of size N, bytewise equal? */
+#if @GNULIB_STRINGEQ@ && !@HAVE_DECL_MEMEQ@
+# ifdef __cplusplus
+extern "C" {
+# endif
+_GL_STRING_INLINE bool
+memeq (void const *__s1, void const *__s2, size_t __n)
+{
+ return !memcmp (__s1, __s2, __n);
+}
+# ifdef __cplusplus
+}
+# endif
+#endif
+
/* Return the first occurrence of NEEDLE in HAYSTACK. */
#if @GNULIB_MEMMEM@
# if @REPLACE_MEMMEM@
@@ -383,7 +508,7 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
# if ! @HAVE_DECL_MEMRCHR@
_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t),
_GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
# endif
/* On some systems, this function is defined as an overloaded function:
extern "C++" { const void * std::memrchr (const void *, int, size_t); }
@@ -420,16 +545,20 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
# define memset_explicit rpl_memset_explicit
# endif
_GL_FUNCDECL_RPL (memset_explicit, void *,
- (void *__dest, int __c, size_t __n), _GL_ARG_NONNULL ((1)));
+ (void *__dest, int __c, size_t __n),
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
_GL_CXXALIAS_RPL (memset_explicit, void *, (void *__dest, int __c, size_t __n));
# else
# if !@HAVE_MEMSET_EXPLICIT@
_GL_FUNCDECL_SYS (memset_explicit, void *,
- (void *__dest, int __c, size_t __n), _GL_ARG_NONNULL ((1)));
+ (void *__dest, int __c, size_t __n),
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
# endif
_GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (memset_explicit);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef memset_explicit
# if HAVE_RAW_DECL_MEMSET_EXPLICIT
@@ -681,6 +810,21 @@ _GL_CXXALIASWARN (strdup);
# endif
#endif
+/* Are strings S1 and S2 equal? */
+#if @GNULIB_STRINGEQ@ && !@HAVE_DECL_STREQ@
+# ifdef __cplusplus
+extern "C" {
+# endif
+_GL_STRING_INLINE bool
+streq (char const *__s1, char const *__s2)
+{
+ return !strcmp (__s1, __s2);
+}
+# ifdef __cplusplus
+}
+# endif
+#endif
+
/* Append no more than N characters from SRC onto DEST. */
#if @GNULIB_STRNCAT@
# if @REPLACE_STRNCAT@
@@ -690,7 +834,8 @@ _GL_CXXALIASWARN (strdup);
# endif
_GL_FUNCDECL_RPL (strncat, char *,
(char *restrict dest, const char *restrict src, size_t n),
- _GL_ARG_NONNULL ((1, 2)));
+ _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
_GL_CXXALIAS_RPL (strncat, char *,
(char *restrict dest, const char *restrict src, size_t n));
# else
@@ -717,7 +862,7 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
# endif
_GL_FUNCDECL_RPL (strndup, char *,
(char const *__s, size_t __n),
- _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
# else
@@ -726,13 +871,13 @@ _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_FUNCDECL_SYS (strndup, char *,
(char const *__s, size_t __n),
- _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
_GL_ATTRIBUTE_NOTHROW;
# else
_GL_FUNCDECL_SYS (strndup, char *,
(char const *__s, size_t __n),
- _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
# endif
# endif
@@ -745,13 +890,13 @@ _GL_CXXALIASWARN (strndup);
# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_FUNCDECL_SYS (strndup, char *,
(char const *__s, size_t __n),
- _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
_GL_ATTRIBUTE_NOTHROW;
# else
_GL_FUNCDECL_SYS (strndup, char *,
(char const *__s, size_t __n),
- _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
# endif
# endif
@@ -1077,13 +1222,29 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
/* The following functions are not specified by POSIX. They are gnulib
extensions. */
+#if @GNULIB_STR_STARTSWITH@
+/* Returns true if STRING starts with PREFIX.
+ Returns false otherwise. */
+_GL_EXTERN_C bool str_startswith (const char *string, const char *prefix)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_STR_ENDSWITH@
+/* Returns true if STRING ends with SUFFIX.
+ Returns false otherwise. */
+_GL_EXTERN_C bool str_endswith (const char *string, const char *prefix)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+
#if @GNULIB_MBSLEN@
/* Return the number of multibyte characters in the character string STRING.
This considers multibyte characters, unlike strlen, which counts bytes. */
# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
# undef mbslen
# endif
-# if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */
+# if @HAVE_MBSLEN@ /* AIX, MirBSD define mbslen already in libc. */
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define mbslen rpl_mbslen
# endif
@@ -1162,6 +1323,33 @@ _GL_CXXALIASWARN (mbsrchr);
_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
_GL_ATTRIBUTE_PURE
_GL_ARG_NONNULL ((1, 2));
+# ifndef _GL_NO_CONST_GENERICS
+/* Don't silently convert a 'const char *' to a 'char *'. Programmers want
+ compiler warnings for 'const' related mistakes. */
+# ifdef __cplusplus
+extern "C++" { /* needed for AIX */
+template <typename T>
+ T * mbsstr_template (T* haystack, const char *needle);
+template <>
+ inline char * mbsstr_template (char *haystack, const char *needle)
+ { return mbsstr (haystack, needle); }
+template <>
+ inline const char * mbsstr_template (const char *haystack, const char *needle)
+ { return mbsstr (haystack, needle); }
+}
+# undef mbsstr
+# define mbsstr mbsstr_template
+# elif !defined mbsstr
+# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
+ || defined __ICC || defined __TINYC__ \
+ || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
+# define mbsstr(h,n) \
+ _Generic ((h), \
+ char const *: (char const *) mbsstr ((h), (n)), \
+ default : mbsstr ((h), (n)))
+# endif
+# endif
+# endif
#endif
#if @GNULIB_MBSCASECMP@
@@ -1203,6 +1391,33 @@ _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
_GL_ATTRIBUTE_PURE
_GL_ARG_NONNULL ((1, 2));
+# ifndef _GL_NO_CONST_GENERICS
+/* Don't silently convert a 'const char *' to a 'char *'. Programmers want
+ compiler warnings for 'const' related mistakes. */
+# ifdef __cplusplus
+extern "C++" { /* needed for AIX */
+template <typename T>
+ T * mbspcasecmp_template (T* string, const char *prefix);
+template <>
+ inline char * mbspcasecmp_template (char *string, const char *prefix)
+ { return mbspcasecmp (string, prefix); }
+template <>
+ inline const char * mbspcasecmp_template (const char *string, const char *prefix)
+ { return mbspcasecmp (string, prefix); }
+}
+# undef mbspcasecmp
+# define mbspcasecmp mbspcasecmp_template
+# elif !defined mbspcasecmp
+# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
+ || defined __ICC || defined __TINYC__ \
+ || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
+# define mbspcasecmp(s,p) \
+ _Generic ((s), \
+ char const *: (char const *) mbspcasecmp ((s), (p)), \
+ default : mbspcasecmp ((s), (p)))
+# endif
+# endif
+# endif
#endif
#if @GNULIB_MBSCASESTR@
@@ -1214,6 +1429,33 @@ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
_GL_ATTRIBUTE_PURE
_GL_ARG_NONNULL ((1, 2));
+# ifndef _GL_NO_CONST_GENERICS
+/* Don't silently convert a 'const char *' to a 'char *'. Programmers want
+ compiler warnings for 'const' related mistakes. */
+# ifdef __cplusplus
+extern "C++" { /* needed for AIX */
+template <typename T>
+ T * mbscasestr_template (T* haystack, const char *needle);
+template <>
+ inline char * mbscasestr_template (char *haystack, const char *needle)
+ { return mbscasestr (haystack, needle); }
+template <>
+ inline const char * mbscasestr_template (const char *haystack, const char *needle)
+ { return mbscasestr (haystack, needle); }
+}
+# undef mbscasestr
+# define mbscasestr mbscasestr_template
+# elif !defined mbscasestr
+# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
+ || defined __ICC || defined __TINYC__ \
+ || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
+# define mbscasestr(h,n) \
+ _Generic ((h), \
+ char const *: (char const *) mbscasestr ((h), (n)), \
+ default : mbscasestr ((h), (n)))
+# endif
+# endif
+# endif
#endif
#if @GNULIB_MBSCSPN@
@@ -1301,6 +1543,26 @@ _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
_GL_ARG_NONNULL ((2, 3));
#endif
+#if @GNULIB_MBS_STARTSWITH@
+/* Returns true if STRING starts with PREFIX.
+ Returns false otherwise. */
+_GL_EXTERN_C bool mbs_startswith (const char *string, const char *prefix)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2));
+/* No extra code is needed for multibyte locales for this function. */
+# define mbs_startswith str_startswith
+#endif
+
+#if @GNULIB_MBS_ENDSWITH@
+/* Returns true if STRING ends with SUFFIX.
+ Returns false otherwise.
+ Unlike str_endswith(), this function works correctly in multibyte locales.
+ */
+_GL_EXTERN_C bool mbs_endswith (const char *string, const char *suffix)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+
/* Map any int, typically from errno, into an error message. */
#if @GNULIB_STRERROR@
# if @REPLACE_STRERROR@
@@ -1352,6 +1614,44 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
# endif
#endif
+/* Map any int, typically from errno, into an error message.
+ With locale_t argument. */
+#if @GNULIB_STRERROR_L@
+# if @REPLACE_STRERROR_L@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strerror_l
+# define strerror_l rpl_strerror_l
+# endif
+_GL_FUNCDECL_RPL (strerror_l, char *, (int errnum, locale_t locale),
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (strerror_l, char *, (int errnum, locale_t locale));
+# else
+# if !@HAVE_STRERROR_L@
+_GL_FUNCDECL_SYS (strerror_l, char *, (int errnum, locale_t locale),
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (strerror_l, char *, (int errnum, locale_t locale));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (strerror_l);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strerror_l
+# if HAVE_RAW_DECL_STRERROR_L
+_GL_WARN_ON_USE (strerror_l, "strerror_l is unportable - "
+ "use gnulib module strerror_l for portability");
+# endif
+#endif
+
+/* Map any int, typically from errno, into an error message. Multithread-safe,
+ with locale_t argument.
+ Not portable! Only provided by gnulib. */
+#if @GNULIB_STRERROR_L@
+_GL_FUNCDECL_SYS (strerror_l_r, int,
+ (int errnum, char *buf, size_t buflen, locale_t locale),
+ _GL_ARG_NONNULL ((2, 4)));
+#endif
+
/* Return the name of the system error code ERRNUM. */
#if @GNULIB_STRERRORNAME_NP@
# if @REPLACE_STRERRORNAME_NP@
@@ -1367,7 +1667,9 @@ _GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum), );
# endif
_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (strerrorname_np);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef strerrorname_np
# if HAVE_RAW_DECL_STRERRORNAME_NP
@@ -1456,6 +1758,7 @@ _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
# endif
#endif
+_GL_INLINE_HEADER_END
#endif /* _@GUARD_PREFIX@_STRING_H */
#endif /* _@GUARD_PREFIX@_STRING_H */