Update from Gnulib by running admin/merge-gnulib

This commit is contained in:
Paul Eggert
2025-04-19 12:18:28 -07:00
parent 30335bb734
commit 71ee484cac
37 changed files with 723 additions and 343 deletions

View File

@@ -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>
@@ -429,7 +434,9 @@ _GL_FUNCDECL_SYS (memset_explicit, void *,
# 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
@@ -1178,6 +1185,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@
@@ -1219,6 +1253,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@
@@ -1230,6 +1291,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@
@@ -1388,6 +1476,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@
@@ -1403,7 +1529,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