From: Bruno Haible Date: Sun, 16 Feb 2025 11:30:58 +0000 (+0100) Subject: strings-h: Don't declare strcasecmp, strncasecmp without the module. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=c17d70aaaebfc79e4d5cc9b490b0cc7d43b5cd42;p=gnulib.git strings-h: Don't declare strcasecmp, strncasecmp without the module. * lib/strings.in.h (strcasecmp): Don't declare if module 'strcasecmp' is not present. (strncasecmp): Don't declare if module 'strncasecmp' is not present. * m4/strings_h.m4 (gl_STRINGS_H_REQUIRE_DEFAULTS): Initialize GNULIB_STRCASECMP, GNULIB_STRNCASECMP. * modules/strings-h (Makefile.am): Substitute GNULIB_STRCASECMP, GNULIB_STRNCASECMP. --- diff --git a/ChangeLog b/ChangeLog index 37255b17ea..65b34ef3fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2025-02-16 Bruno Haible + + strings-h: Don't declare strcasecmp, strncasecmp without the module. + * lib/strings.in.h (strcasecmp): Don't declare if module 'strcasecmp' is + not present. + (strncasecmp): Don't declare if module 'strncasecmp' is not present. + * m4/strings_h.m4 (gl_STRINGS_H_REQUIRE_DEFAULTS): Initialize + GNULIB_STRCASECMP, GNULIB_STRNCASECMP. + * modules/strings-h (Makefile.am): Substitute GNULIB_STRCASECMP, + GNULIB_STRNCASECMP. + 2025-02-16 Bruno Haible strcasecmp, strncasecmp: New modules. diff --git a/lib/strings.in.h b/lib/strings.in.h index f99b7c95e8..d7bd1ae917 100644 --- a/lib/strings.in.h +++ b/lib/strings.in.h @@ -58,8 +58,8 @@ extern "C" { #endif - /* Find the index of the least-significant set bit. */ #if @GNULIB_FFS@ +/* Find the index of the least-significant set bit. */ # if !@HAVE_FFS@ _GL_FUNCDECL_SYS (ffs, int, (int i), ); # endif @@ -72,15 +72,16 @@ _GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module"); # endif #endif +#if @GNULIB_STRCASECMP@ /* Compare strings S1 and S2, ignoring case, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. Note: This function does not work in multibyte locales. */ -#if ! @HAVE_STRCASECMP@ +# if ! @HAVE_STRCASECMP@ extern int strcasecmp (char const *s1, char const *s2) _GL_ARG_NONNULL ((1, 2)); -#endif -#if defined GNULIB_POSIXCHECK +# endif +#elif defined GNULIB_POSIXCHECK /* strcasecmp() does not work with multibyte strings: POSIX says that it operates on "strings", and "string" in POSIX is defined as a sequence of bytes, not of characters. */ @@ -95,15 +96,16 @@ _GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character " # endif #endif +#if @GNULIB_STRNCASECMP@ /* Compare no more than N bytes of strings S1 and S2, ignoring case, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. Note: This function cannot work correctly in multibyte locales. */ -#if ! @HAVE_DECL_STRNCASECMP@ +# if ! @HAVE_DECL_STRNCASECMP@ extern int strncasecmp (char const *s1, char const *s2, size_t n) _GL_ARG_NONNULL ((1, 2)); -#endif -#if defined GNULIB_POSIXCHECK +# endif +#elif defined GNULIB_POSIXCHECK /* strncasecmp() does not work with multibyte strings: POSIX says that it operates on "strings", and "string" in POSIX is defined as a sequence of bytes, not of characters. */ diff --git a/m4/strings_h.m4 b/m4/strings_h.m4 index c6f40fcdfa..25596aa445 100644 --- a/m4/strings_h.m4 +++ b/m4/strings_h.m4 @@ -1,5 +1,5 @@ # strings_h.m4 -# serial 9 +# serial 10 dnl Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -50,6 +50,8 @@ AC_DEFUN([gl_STRINGS_H_REQUIRE_DEFAULTS], [ m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS], [ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCASECMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCASECMP]) ]) m4_require(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS]) AC_REQUIRE([gl_STRINGS_H_DEFAULTS]) diff --git a/modules/strings-h b/modules/strings-h index ad05ba3314..7b3cc6ad44 100644 --- a/modules/strings-h +++ b/modules/strings-h @@ -33,6 +33,8 @@ strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \ -e 's/@''GNULIB_FFS''@/$(GNULIB_FFS)/g' \ + -e 's/@''GNULIB_STRCASECMP''@/$(GNULIB_STRCASECMP)/g' \ + -e 's/@''GNULIB_STRNCASECMP''@/$(GNULIB_STRNCASECMP)/g' \ -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \ -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \ -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \