diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2026-03-01 10:28:33 -0800 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2026-03-01 10:41:54 -0800 |
| commit | 381eb4985b7854747cb1102232d801abd98948f6 (patch) | |
| tree | d3011fb7c1b13e13eac4245ad4a527983a27cda4 /lib | |
| parent | b715ae5b34ddb74a5f537707a370fc70deac04a1 (diff) | |
Update from Gnulib by running admin/merge-gnulib
* admin/merge-gnulib (GNULIB_MODULES): Add memeq, streq and remove
stringeq, to adjust to a module splitup in Gnulib.
* lib/memeq.c, lib/streq.c, lib/strnul.c, m4/memeq.m4, m4/streq.m4:
New files.
* lib/string.c, m4/stringeq.m4: Remove.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/file-has-acl.c | 2 | ||||
| -rw-r--r-- | lib/gnulib.mk.in | 41 | ||||
| -rw-r--r-- | lib/memeq.c (renamed from lib/string.c) | 4 | ||||
| -rw-r--r-- | lib/sha3.c | 2 | ||||
| -rw-r--r-- | lib/streq.c | 19 | ||||
| -rw-r--r-- | lib/strftime.c | 5 | ||||
| -rw-r--r-- | lib/string.in.h | 39 | ||||
| -rw-r--r-- | lib/strnul.c | 19 | ||||
| -rw-r--r-- | lib/time_rz.c | 2 |
9 files changed, 101 insertions, 32 deletions
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index 26d3e358de7..3269d7f71b7 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c @@ -145,7 +145,7 @@ aclinfo_has_xattr (struct aclinfo const *ai, char const *xattr) if (0 < ai->size) { char const *blim = ai->buf + ai->size; - for (char const *b = ai->buf; b < blim; b += strlen (b) + 1) + for (char const *b = ai->buf; b < blim; b = strnul (b) + 1) for (char const *a = xattr; *a == *b; a++, b++) if (!*a) return true; diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 053d234a474..824931caf90 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -140,6 +140,7 @@ # lstat \ # malloc-gnu \ # manywarnings \ +# memeq \ # memmem-simple \ # mempcpy \ # memrchr \ @@ -172,7 +173,7 @@ # stdio-h \ # stdio-windows \ # stpcpy \ -# stringeq \ +# streq \ # strnlen \ # strtoimax \ # symlink \ @@ -537,6 +538,7 @@ GL_GNULIB_MDA_UMASK = @GL_GNULIB_MDA_UMASK@ GL_GNULIB_MDA_UNLINK = @GL_GNULIB_MDA_UNLINK@ GL_GNULIB_MDA_WRITE = @GL_GNULIB_MDA_WRITE@ GL_GNULIB_MEMCHR = @GL_GNULIB_MEMCHR@ +GL_GNULIB_MEMEQ = @GL_GNULIB_MEMEQ@ GL_GNULIB_MEMMEM = @GL_GNULIB_MEMMEM@ GL_GNULIB_MEMPCPY = @GL_GNULIB_MEMPCPY@ GL_GNULIB_MEMRCHR = @GL_GNULIB_MEMRCHR@ @@ -626,12 +628,12 @@ GL_GNULIB_STPNCPY = @GL_GNULIB_STPNCPY@ GL_GNULIB_STRCASESTR = @GL_GNULIB_STRCASESTR@ GL_GNULIB_STRCHRNUL = @GL_GNULIB_STRCHRNUL@ GL_GNULIB_STRDUP = @GL_GNULIB_STRDUP@ +GL_GNULIB_STREQ = @GL_GNULIB_STREQ@ GL_GNULIB_STRERROR = @GL_GNULIB_STRERROR@ GL_GNULIB_STRERRORNAME_NP = @GL_GNULIB_STRERRORNAME_NP@ GL_GNULIB_STRERROR_L = @GL_GNULIB_STRERROR_L@ GL_GNULIB_STRERROR_R = @GL_GNULIB_STRERROR_R@ GL_GNULIB_STRFTIME = @GL_GNULIB_STRFTIME@ -GL_GNULIB_STRINGEQ = @GL_GNULIB_STRINGEQ@ GL_GNULIB_STRNCAT = @GL_GNULIB_STRNCAT@ GL_GNULIB_STRNCPY = @GL_GNULIB_STRNCPY@ GL_GNULIB_STRNDUP = @GL_GNULIB_STRNDUP@ @@ -2790,6 +2792,14 @@ EXTRA_libgnu_a_SOURCES += malloc.c endif ## end gnulib module malloc-posix +## begin gnulib module memeq +ifeq (,$(OMIT_GNULIB_MODULE_memeq)) + +libgnu_a_SOURCES += memeq.c + +endif +## end gnulib module memeq + ## begin gnulib module memmem-simple ifeq (,$(OMIT_GNULIB_MODULE_memmem-simple)) @@ -3729,6 +3739,14 @@ endif endif ## end gnulib module stpcpy +## begin gnulib module streq +ifeq (,$(OMIT_GNULIB_MODULE_streq)) + +libgnu_a_SOURCES += streq.c + +endif +## end gnulib module streq + ## begin gnulib module string-h ifeq (,$(OMIT_GNULIB_MODULE_string-h)) @@ -3763,6 +3781,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's/@''GNULIB_MBS_ENDSWITH''@/$(GL_GNULIB_MBS_ENDSWITH)/g' \ -e 's/@''GNULIB_MBS_STARTSWITH''@/$(GL_GNULIB_MBS_STARTSWITH)/g' \ -e 's/@''GNULIB_MEMCHR''@/$(GL_GNULIB_MEMCHR)/g' \ + -e 's/@''GNULIB_MEMEQ''@/$(GL_GNULIB_MEMEQ)/g' \ -e 's/@''GNULIB_MEMMEM''@/$(GL_GNULIB_MEMMEM)/g' \ -e 's/@''GNULIB_MEMPCPY''@/$(GL_GNULIB_MEMPCPY)/g' \ -e 's/@''GNULIB_MEMRCHR''@/$(GL_GNULIB_MEMRCHR)/g' \ @@ -3772,7 +3791,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's/@''GNULIB_STPNCPY''@/$(GL_GNULIB_STPNCPY)/g' \ -e 's/@''GNULIB_STRCHRNUL''@/$(GL_GNULIB_STRCHRNUL)/g' \ -e 's/@''GNULIB_STRDUP''@/$(GL_GNULIB_STRDUP)/g' \ - -e 's/@''GNULIB_STRINGEQ''@/$(GL_GNULIB_STRINGEQ)/g' \ + -e 's/@''GNULIB_STREQ''@/$(GL_GNULIB_STREQ)/g' \ -e 's/@''GNULIB_STRNCAT''@/$(GL_GNULIB_STRNCAT)/g' \ -e 's/@''GNULIB_STRNCPY''@/$(GL_GNULIB_STRNCPY)/g' \ -e 's/@''GNULIB_STRNDUP''@/$(GL_GNULIB_STRNDUP)/g' \ @@ -3863,14 +3882,6 @@ EXTRA_DIST += string.in.h endif ## end gnulib module string-h -## begin gnulib module stringeq -ifeq (,$(OMIT_GNULIB_MODULE_stringeq)) - -libgnu_a_SOURCES += string.c - -endif -## end gnulib module stringeq - ## begin gnulib module strnlen ifeq (,$(OMIT_GNULIB_MODULE_strnlen)) @@ -3881,6 +3892,14 @@ endif endif ## end gnulib module strnlen +## begin gnulib module strnul +ifeq (,$(OMIT_GNULIB_MODULE_strnul)) + +libgnu_a_SOURCES += strnul.c + +endif +## end gnulib module strnul + ## begin gnulib module strtoimax ifeq (,$(OMIT_GNULIB_MODULE_strtoimax)) diff --git a/lib/string.c b/lib/memeq.c index b8f079aa78f..9cefacd9495 100644 --- a/lib/string.c +++ b/lib/memeq.c @@ -1,4 +1,4 @@ -/* streq, memeq, gl_strnul functions. +/* memeq function. Copyright (C) 2025-2026 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify @@ -14,6 +14,6 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#define _GL_STRING_INLINE _GL_EXTERN_INLINE +#define _GL_MEMEQ_INLINE _GL_EXTERN_INLINE #include <config.h> #include <string.h> diff --git a/lib/sha3.c b/lib/sha3.c index 1bebbc76950..e7cb5ab5494 100644 --- a/lib/sha3.c +++ b/lib/sha3.c @@ -378,7 +378,7 @@ sha3_read_ctx (struct sha3_ctx const *restrict ctx, void *restrict resbuf) { if (EVP_MD_CTX_copy_ex (evp_ctx, ctx->evp_ctx)) { - if (EVP_DigestFinal_ex (evp_ctx, resbuf, 0)) + if (EVP_DigestFinal_ex (evp_ctx, resbuf, NULL)) result = resbuf; err = EINVAL; } diff --git a/lib/streq.c b/lib/streq.c new file mode 100644 index 00000000000..69b0d7b7843 --- /dev/null +++ b/lib/streq.c @@ -0,0 +1,19 @@ +/* streq function. + Copyright (C) 2025-2026 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 + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +#define _GL_STREQ_INLINE _GL_EXTERN_INLINE +#include <config.h> +#include <string.h> diff --git a/lib/strftime.c b/lib/strftime.c index 8d32023729c..f7cf65d5413 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -888,6 +888,7 @@ static CHAR_T const c_month_names[][sizeof "September"] = L_("June"), L_("July"), L_("August"), L_("September"), L_("October"), L_("November"), L_("December") }; +static CHAR_T const c_ampm_letters[] = { L_('A'), L_('M'), L_('P'), L_('M') }; #endif @@ -1274,7 +1275,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) # define f_month \ (tp->tm_mon < 0 || tp->tm_mon > 11 ? L_("?") : c_month_names[tp->tm_mon]) /* The English AM/PM strings happen to have the same length, namely 2. */ -# define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11)) +# define ampm (c_ampm_letters + 2 * (12 <= tp->tm_hour)) # define ap_len 2 #endif retval_t i = 0; @@ -1358,7 +1359,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) mbstate_t mbstate = mbstate_zero; if (! format_end) - format_end = f + strlen (f) + 1; + format_end = strnul (f) + 1; size_t fsize = format_end - f; size_t len = 0; diff --git a/lib/string.in.h b/lib/string.in.h index 599203c44db..0cd83c7844f 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -81,9 +81,14 @@ #endif _GL_INLINE_HEADER_BEGIN - -#ifndef _GL_STRING_INLINE -# define _GL_STRING_INLINE _GL_INLINE +#ifndef _GL_MEMEQ_INLINE +# define _GL_MEMEQ_INLINE _GL_INLINE +#endif +#ifndef _GL_STREQ_INLINE +# define _GL_STREQ_INLINE _GL_INLINE +#endif +#ifndef _GL_STRNUL_INLINE +# define _GL_STRNUL_INLINE _GL_INLINE #endif /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers @@ -414,11 +419,11 @@ _GL_WARN_ON_USE_CXX (memchr, #endif /* Are S1 and S2, of size N, bytewise equal? */ -#if @GNULIB_STRINGEQ@ && !@HAVE_DECL_MEMEQ@ +#if @GNULIB_MEMEQ@ && !@HAVE_DECL_MEMEQ@ # ifdef __cplusplus extern "C" { # endif -_GL_STRING_INLINE bool +_GL_MEMEQ_INLINE bool memeq (void const *__s1, void const *__s2, size_t __n) { return !memcmp (__s1, __s2, __n); @@ -799,11 +804,11 @@ _GL_CXXALIASWARN (strdup); #endif /* Are strings S1 and S2 equal? */ -#if @GNULIB_STRINGEQ@ && !@HAVE_DECL_STREQ@ +#if @GNULIB_STREQ@ && !@HAVE_DECL_STREQ@ # ifdef __cplusplus extern "C" { # endif -_GL_STRING_INLINE bool +_GL_STREQ_INLINE bool streq (char const *__s1, char const *__s2) { return !strcmp (__s1, __s2); @@ -1243,10 +1248,10 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " # ifdef __cplusplus extern "C" { # endif -_GL_STRING_INLINE const char *gl_strnul (const char *string) +_GL_STRNUL_INLINE const char *gl_strnul (const char *string) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1)); -_GL_STRING_INLINE const char *gl_strnul (const char *string) +_GL_STRNUL_INLINE const char *gl_strnul (const char *string) { /* In gcc >= 7 or clang >= 4, we could use the expression strchr (string, '\0') @@ -1260,21 +1265,29 @@ _GL_STRING_INLINE const char *gl_strnul (const char *string) } # endif # ifdef __cplusplus +_GL_BEGIN_NAMESPACE template <typename T> T strnul (T); template <> inline const char *strnul<const char *> (const char *s) { return gl_strnul (s); } template <> inline char *strnul< char *> ( char *s) { return const_cast<char *>(gl_strnul (s)); } +_GL_END_NAMESPACE # else # if (defined __GNUC__ && __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 && !defined __cplusplus) \ || (defined __clang__ && __clang_major__ >= 3) \ || (defined __SUNPRO_C && __SUNPRO_C >= 0x5150) \ || (__STDC_VERSION__ >= 201112L && !defined __GNUC__) /* The compiler supports _Generic from ISO C11. */ +/* Since in C (but not in C++!), any function that accepts a '[const] char *' + also accepts a '[const] void *' as argument, we make sure that the function- + like macro does the same, by mapping its type first: + char *, void * -> void * + const char *, const void * -> const void * + This mapping is done through the conditional expression. */ # define strnul(s) \ - _Generic (s, \ - char * : (char *) gl_strnul (s), \ - const char * : gl_strnul (s)) + _Generic (1 ? (s) : (void *) 99, \ + void * : (char *) gl_strnul (s), \ + const void * : gl_strnul (s)) # else # define strnul(s) \ ((char *) gl_strnul (s)) @@ -1609,8 +1622,6 @@ _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim, _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@ diff --git a/lib/strnul.c b/lib/strnul.c new file mode 100644 index 00000000000..a567f0722ec --- /dev/null +++ b/lib/strnul.c @@ -0,0 +1,19 @@ +/* gl_strnul function. + Copyright (C) 2025-2026 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 + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +#define _GL_STRNUL_INLINE _GL_EXTERN_INLINE +#include <config.h> +#include <string.h> diff --git a/lib/time_rz.c b/lib/time_rz.c index 811240e6da1..0e8ea47e791 100644 --- a/lib/time_rz.c +++ b/lib/time_rz.c @@ -146,7 +146,7 @@ save_abbr (timezone_t tz, struct tm *tm) break; } - zone_copy += strlen (zone_copy) + 1; + zone_copy = strnul (zone_copy) + 1; if (!*zone_copy && tz->next) { tz = tz->next; |
