1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2025-08-08 17:22:05 +03:00

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.
This commit is contained in:
Bruno Haible
2025-02-16 12:30:58 +01:00
parent b2927d1b1f
commit c17d70aaae
4 changed files with 25 additions and 8 deletions

View File

@@ -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> 2025-02-16 Bruno Haible <bruno@clisp.org>
strcasecmp, strncasecmp: New modules. strcasecmp, strncasecmp: New modules.

View File

@@ -58,8 +58,8 @@ extern "C" {
#endif #endif
/* Find the index of the least-significant set bit. */
#if @GNULIB_FFS@ #if @GNULIB_FFS@
/* Find the index of the least-significant set bit. */
# if !@HAVE_FFS@ # if !@HAVE_FFS@
_GL_FUNCDECL_SYS (ffs, int, (int i), ); _GL_FUNCDECL_SYS (ffs, int, (int i), );
# endif # endif
@@ -72,15 +72,16 @@ _GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module");
# endif # endif
#endif #endif
#if @GNULIB_STRCASECMP@
/* Compare strings S1 and S2, ignoring case, returning less than, equal to or /* 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 greater than zero if S1 is lexicographically less than, equal to or greater
than S2. than S2.
Note: This function does not work in multibyte locales. */ Note: This function does not work in multibyte locales. */
#if ! @HAVE_STRCASECMP@ # if ! @HAVE_STRCASECMP@
extern int strcasecmp (char const *s1, char const *s2) extern int strcasecmp (char const *s1, char const *s2)
_GL_ARG_NONNULL ((1, 2)); _GL_ARG_NONNULL ((1, 2));
#endif # endif
#if defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
/* strcasecmp() does not work with multibyte strings: /* strcasecmp() does not work with multibyte strings:
POSIX says that it operates on "strings", and "string" in POSIX is defined POSIX says that it operates on "strings", and "string" in POSIX is defined
as a sequence of bytes, not of characters. */ 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
#endif #endif
#if @GNULIB_STRNCASECMP@
/* Compare no more than N bytes of strings S1 and S2, ignoring case, /* 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 returning less than, equal to or greater than zero if S1 is
lexicographically less than, equal to or greater than S2. lexicographically less than, equal to or greater than S2.
Note: This function cannot work correctly in multibyte locales. */ 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) extern int strncasecmp (char const *s1, char const *s2, size_t n)
_GL_ARG_NONNULL ((1, 2)); _GL_ARG_NONNULL ((1, 2));
#endif # endif
#if defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
/* strncasecmp() does not work with multibyte strings: /* strncasecmp() does not work with multibyte strings:
POSIX says that it operates on "strings", and "string" in POSIX is defined POSIX says that it operates on "strings", and "string" in POSIX is defined
as a sequence of bytes, not of characters. */ as a sequence of bytes, not of characters. */

View File

@@ -1,5 +1,5 @@
# strings_h.m4 # strings_h.m4
# serial 9 # serial 10
dnl Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc. dnl Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, 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], [ m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS], [
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFS]) 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]) m4_require(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS])
AC_REQUIRE([gl_STRINGS_H_DEFAULTS]) AC_REQUIRE([gl_STRINGS_H_DEFAULTS])

View 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|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \ -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
-e 's/@''GNULIB_FFS''@/$(GNULIB_FFS)/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_FFS''@|$(HAVE_FFS)|g' \
-e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \ -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
-e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \ -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \