]> Savannah Git Hosting - gnulib.git/commitdiff
strings-h: Don't declare strcasecmp, strncasecmp without the module.
authorBruno Haible <bruno@clisp.org>
Sun, 16 Feb 2025 11:30:58 +0000 (12:30 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 16 Feb 2025 12:45:36 +0000 (13:45 +0100)
* 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.

ChangeLog
lib/strings.in.h
m4/strings_h.m4
modules/strings-h

index 37255b17eaf1e45d9912c2d43752f61234cc495d..65b34ef3fc169acf18879997decb642bd26bcc4c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2025-02-16  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        strcasecmp, strncasecmp: New modules.
index f99b7c95e8afa7fe5f88a8c80851a5bbb059a0a5..d7bd1ae9171cbf1222f4bd63f87916daad9b6803 100644 (file)
@@ -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.  */
index c6f40fcdfa18c371832e710d31b07aeb5f7f33b6..25596aa445cbdf416d48a7dab9d28f5ee97625b3 100644 (file)
@@ -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])
index ad05ba3314d320e4d6e14ccc832111c52b094861..7b3cc6ad441a0dc4cdc2cc8367e8a3f3f5e566f6 100644 (file)
@@ -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' \