]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
c-strcasecmp, c-strncasecmp: New modules.
authorBruno Haible <bruno@clisp.org>
Sun, 16 Feb 2025 12:02:25 +0000 (13:02 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 16 Feb 2025 12:45:36 +0000 (13:45 +0100)
* modules/c-strcasecmp: New file.
* modules/c-strncasecmp: New file.
* modules/c-strcase: Merely depend on c-strcasecmp, c-strncasecmp.
* lib/strings.in.h (strcasecmp, strncasecmp): Update warning message.
* tests/test-c-strcasecmp.sh: New file, based on
tests/test-c-strcase.sh.
* tests/test-c-strncasecmp.sh: New file, based on
tests/test-c-strcase.sh.
* tests/test-c-strcase.sh: Remove file.
* modules/c-strcasecmp-tests: New file.
* modules/c-strncasecmp-tests: New file.
* modules/c-strcase-tests: Remove file.
* doc/c-strcasecmp.texi: New file, based on doc/c-strcase.texi.
* doc/c-strncasecmp.texi: New file, based on doc/c-strcase.texi.
* doc/c-strcase.texi: Remove file.
* doc/c-locale.texi: Include c-strcasecmp.texi and c-strncasecmp.texi
separately.
* modules/c-strcaseeq (Depends-on): Add c-strcasecmp. Remove c-strcase.
* modules/iconv_open (Depends-on): Likewise.
* modules/nl_langinfo-tests (Depends-on): Likewise.
* modules/propername (Depends-on): Likewise.
* modules/propername-lite (Depends-on): Likewise.
* modules/striconv (Depends-on): Likewise.
* modules/striconveh (Depends-on): Likewise.
* modules/striconveha (Depends-on): Likewise.
* modules/c-strcasestr (Depends-on): Add c-strncasecmp. Remove
c-strcase.

21 files changed:
ChangeLog
doc/c-locale.texi
doc/c-strcasecmp.texi [new file with mode: 0644]
doc/c-strncasecmp.texi [moved from doc/c-strcase.texi with 62% similarity]
lib/strings.in.h
modules/c-strcase
modules/c-strcasecmp [new file with mode: 0644]
modules/c-strcasecmp-tests [new file with mode: 0644]
modules/c-strcaseeq
modules/c-strcasestr
modules/c-strncasecmp [new file with mode: 0644]
modules/c-strncasecmp-tests [moved from modules/c-strcase-tests with 63% similarity]
modules/iconv_open
modules/nl_langinfo-tests
modules/propername
modules/propername-lite
modules/striconv
modules/striconveh
modules/striconveha
tests/test-c-strcasecmp.sh [new file with mode: 0755]
tests/test-c-strncasecmp.sh [moved from tests/test-c-strcase.sh with 69% similarity]

index 65b34ef3fc169acf18879997decb642bd26bcc4c..5829c3bd9e636340e1c3f3dacc3b619e8fc13e9e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2025-02-16  Bruno Haible  <bruno@clisp.org>
+
+       c-strcasecmp, c-strncasecmp: New modules.
+       * modules/c-strcasecmp: New file.
+       * modules/c-strncasecmp: New file.
+       * modules/c-strcase: Merely depend on c-strcasecmp, c-strncasecmp.
+       * lib/strings.in.h (strcasecmp, strncasecmp): Update warning message.
+       * tests/test-c-strcasecmp.sh: New file, based on
+       tests/test-c-strcase.sh.
+       * tests/test-c-strncasecmp.sh: New file, based on
+       tests/test-c-strcase.sh.
+       * tests/test-c-strcase.sh: Remove file.
+       * modules/c-strcasecmp-tests: New file.
+       * modules/c-strncasecmp-tests: New file.
+       * modules/c-strcase-tests: Remove file.
+       * doc/c-strcasecmp.texi: New file, based on doc/c-strcase.texi.
+       * doc/c-strncasecmp.texi: New file, based on doc/c-strcase.texi.
+       * doc/c-strcase.texi: Remove file.
+       * doc/c-locale.texi: Include c-strcasecmp.texi and c-strncasecmp.texi
+       separately.
+       * modules/c-strcaseeq (Depends-on): Add c-strcasecmp. Remove c-strcase.
+       * modules/iconv_open (Depends-on): Likewise.
+       * modules/nl_langinfo-tests (Depends-on): Likewise.
+       * modules/propername (Depends-on): Likewise.
+       * modules/propername-lite (Depends-on): Likewise.
+       * modules/striconv (Depends-on): Likewise.
+       * modules/striconveh (Depends-on): Likewise.
+       * modules/striconveha (Depends-on): Likewise.
+       * modules/c-strcasestr (Depends-on): Add c-strncasecmp. Remove
+       c-strcase.
+
 2025-02-16  Bruno Haible  <bruno@clisp.org>
 
        strings-h: Don't declare strcasecmp, strncasecmp without the module.
index b9f62748738c45531c713c89523f3b0b2cc4f4ab..41b17a3980aa6c1d3a4e29ed27ded44907bef196 100644 (file)
@@ -16,8 +16,9 @@ The functions are provided by the following modules.
 
 @menu
 * c-ctype::
-* c-strcase::
 * c-strcaseeq::
+* c-strcasecmp::
+* c-strncasecmp::
 * c-strcasestr::
 * c-strstr::
 * c-strtod::
@@ -28,14 +29,18 @@ The functions are provided by the following modules.
 @subsubsection c-ctype
 @include c-ctype.texi
 
-@node c-strcase
-@subsubsection c-strcase
-@include c-strcase.texi
-
 @node c-strcaseeq
 @subsubsection c-strcaseeq
 @include c-strcaseeq.texi
 
+@node c-strcasecmp
+@subsubsection c-strcasecmp
+@include c-strcasecmp.texi
+
+@node c-strncasecmp
+@subsubsection c-strncasecmp
+@include c-strncasecmp.texi
+
 @node c-strcasestr
 @subsubsection c-strcasestr
 @include c-strcasestr.texi
diff --git a/doc/c-strcasecmp.texi b/doc/c-strcasecmp.texi
new file mode 100644 (file)
index 0000000..971d021
--- /dev/null
@@ -0,0 +1,29 @@
+@c Documentation of gnulib module 'c-strcasecmp'.
+
+@c Copyright (C) 2008--2025 Free Software Foundation, Inc.
+
+@c Permission is granted to copy, distribute and/or modify this document
+@c under the terms of the GNU Free Documentation License, Version 1.3 or
+@c any later version published by the Free Software Foundation; with no
+@c Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.  A
+@c copy of the license is at <https://www.gnu.org/licenses/fdl-1.3.en.html>.
+
+@mindex c-strcasecmp
+The @code{c-strcasecmp} module contains a case-insensitive string comparison
+function operating on single-byte character strings, like the functions in
+@code{<strings.h>}, that operate as if the locale encoding was ASCII.
+(The "C" locale on many systems has the locale encoding "ASCII".)
+
+The function is:
+@smallexample
+extern int c_strcasecmp (const char *s1, const char *s2);
+@end smallexample
+
+For case conversion here, only ASCII characters are considered to be
+upper case or lower case.
+
+Note: The function @code{strcasecmp} from @code{<strings.h>}
+supports only unibyte locales;
+@mindex mbscasecmp
+for multibyte locales,
+you need the function @code{mbscasecmp}.
similarity index 62%
rename from doc/c-strcase.texi
rename to doc/c-strncasecmp.texi
index 5c31fecc36da26ebbb70b0093c649dcf99e84f34..61ed3d5ae0958986d0b192ff784a57c15e9402ef 100644 (file)
@@ -1,4 +1,4 @@
-@c Documentation of gnulib module 'c-strcase'.
+@c Documentation of gnulib module 'c-strncasecmp'.
 
 @c Copyright (C) 2008--2025 Free Software Foundation, Inc.
 
@@ -8,26 +8,23 @@
 @c Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.  A
 @c copy of the license is at <https://www.gnu.org/licenses/fdl-1.3.en.html>.
 
-@mindex c-strcase
-The @code{c-strcase} module contains case-insensitive string comparison
-functions operating on single-byte character strings, like the functions in
+@mindex c-strncasecmp
+The @code{c-strncasecmp} module contains a case-insensitive string comparison
+function operating on single-byte character strings, like the functions in
 @code{<strings.h>}, that operate as if the locale encoding was ASCII.
 (The "C" locale on many systems has the locale encoding "ASCII".)
 
-The functions are:
+The function is:
 @smallexample
-extern int c_strcasecmp (const char *s1, const char *s2);
 extern int c_strncasecmp (const char *s1, const char *s2, size_t n);
 @end smallexample
 
 For case conversion here, only ASCII characters are considered to be
 upper case or lower case.
 
-Note: The functions @code{strcasecmp}, @code{strncasecmp} from
-@code{<strings.h>} support only unibyte locales;
-@mindex mbscasecmp
+Note: The function @code{strncasecmp} from @code{<strings.h>}
+supports only unibyte locales;
 @mindex mbsncasecmp
 @mindex mbspcasecmp
 for multibyte locales,
-you need the functions @code{mbscasecmp}, @code{mbsncasecmp},
-@code{mbspcasecmp}.
+you need the function @code{mbsncasecmp} or @code{mbspcasecmp}.
index d7bd1ae9171cbf1222f4bd63f87916daad9b6803..cad01dc34b6ced0e05ed0460568470d8cd6a1bb6 100644 (file)
@@ -91,7 +91,7 @@ _GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
                  "strings in multibyte locales - "
                  "use mbscasecmp if you care about "
                  "internationalization, or use c_strcasecmp "
-                 "(gnulib module c-strcase) if you want a locale "
+                 "(gnulib module c-strcasecmp) if you want a locale "
                  "independent function");
 # endif
 #endif
@@ -115,7 +115,7 @@ _GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
                  "strings in multibyte locales - "
                  "use mbsncasecmp or mbspcasecmp if you care about "
                  "internationalization, or use c_strncasecmp "
-                 "(gnulib module c-strcase) if you want a locale "
+                 "(gnulib module c-strncasecmp) if you want a locale "
                  "independent function");
 # endif
 #endif
index 1af2c8ee9e3602a938835f06343b953b44ec902b..10fc5a5ab39c2a9282ff3ac3d125e40ad089e570 100644 (file)
@@ -2,17 +2,14 @@ Description:
 Case-insensitive string comparison functions in C locale.
 
 Files:
-lib/c-strcase.h
-lib/c-strcasecmp.c
-lib/c-strncasecmp.c
 
 Depends-on:
-c-ctype
+c-strcasecmp
+c-strncasecmp
 
 configure.ac:
 
 Makefile.am:
-lib_SOURCES += c-strcase.h c-strcasecmp.c c-strncasecmp.c
 
 Include:
 "c-strcase.h"
diff --git a/modules/c-strcasecmp b/modules/c-strcasecmp
new file mode 100644 (file)
index 0000000..d9afa54
--- /dev/null
@@ -0,0 +1,23 @@
+Description:
+Case-insensitive string comparison functions in C locale.
+
+Files:
+lib/c-strcase.h
+lib/c-strcasecmp.c
+
+Depends-on:
+c-ctype
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += c-strcasecmp.c
+
+Include:
+"c-strcase.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+all
diff --git a/modules/c-strcasecmp-tests b/modules/c-strcasecmp-tests
new file mode 100644 (file)
index 0000000..6f5b0d2
--- /dev/null
@@ -0,0 +1,21 @@
+Files:
+tests/test-c-strcasecmp.sh
+tests/test-c-strcasecmp.c
+tests/macros.h
+m4/locale-fr.m4
+m4/locale-tr.m4
+m4/codeset.m4
+
+Depends-on:
+c-ctype
+setlocale
+
+configure.ac:
+gt_LOCALE_FR
+gt_LOCALE_TR_UTF8
+
+Makefile.am:
+TESTS += test-c-strcasecmp.sh
+TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_TR_UTF8='@LOCALE_TR_UTF8@'
+check_PROGRAMS += test-c-strcasecmp
+test_c_strcasecmp_LDADD = $(LDADD) $(SETLOCALE_LIB)
index 7569bc6697a10e3824ef13db7bb59cf796ef0bcc..90c36058056b92870bcd05d0c3f82e2dbb475d4f 100644 (file)
@@ -5,7 +5,7 @@ Files:
 lib/c-strcaseeq.h
 
 Depends-on:
-c-strcase
+c-strcasecmp
 c-ctype
 
 configure.ac:
index 0bc5a81b1bbd3ba78d66b852e62032f2219bec18..3cc0b979b87b2472d2ec7dde7b819f55266832c7 100644 (file)
@@ -8,7 +8,7 @@ lib/str-two-way.h
 
 Depends-on:
 c-ctype
-c-strcase
+c-strncasecmp
 bool
 memchr
 memcmp
diff --git a/modules/c-strncasecmp b/modules/c-strncasecmp
new file mode 100644 (file)
index 0000000..f2b0cf0
--- /dev/null
@@ -0,0 +1,23 @@
+Description:
+Case-insensitive string comparison functions in C locale.
+
+Files:
+lib/c-strcase.h
+lib/c-strncasecmp.c
+
+Depends-on:
+c-ctype
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += c-strncasecmp.c
+
+Include:
+"c-strcase.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+all
similarity index 63%
rename from modules/c-strcase-tests
rename to modules/c-strncasecmp-tests
index 23a3eb8aba9e5721abe841134258b18075040657..7e7c94535f5d41e25e672d5b60438669539c267b 100644 (file)
@@ -1,6 +1,5 @@
 Files:
-tests/test-c-strcase.sh
-tests/test-c-strcasecmp.c
+tests/test-c-strncasecmp.sh
 tests/test-c-strncasecmp.c
 tests/macros.h
 m4/locale-fr.m4
@@ -16,8 +15,7 @@ gt_LOCALE_FR
 gt_LOCALE_TR_UTF8
 
 Makefile.am:
-TESTS += test-c-strcase.sh
+TESTS += test-c-strncasecmp.sh
 TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_TR_UTF8='@LOCALE_TR_UTF8@'
-check_PROGRAMS += test-c-strcasecmp test-c-strncasecmp
-test_c_strcasecmp_LDADD = $(LDADD) $(SETLOCALE_LIB)
+check_PROGRAMS += test-c-strncasecmp
 test_c_strncasecmp_LDADD = $(LDADD) $(SETLOCALE_LIB)
index 4993a0704496428d34d9fa95403696e754159f40..b3ed95c40f7a914817885fa5c1ffb3993e8dddb3 100644 (file)
@@ -18,7 +18,7 @@ gperf
 iconv-h
 iconv
 c-ctype           [test $REPLACE_ICONV_OPEN = 1]
-c-strcase         [test $REPLACE_ICONV_OPEN = 1]
+c-strcasecmp      [test $REPLACE_ICONV_OPEN = 1]
 stdint-h          [test $REPLACE_ICONV_UTF = 1]
 unistr/u8-mbtoucr [test $REPLACE_ICONV_UTF = 1]
 unistr/u8-uctomb  [test $REPLACE_ICONV_UTF = 1]
index 66bae5ffaf3a09ed02181e3326bfa1ec70824773..a1125e290c827c679444026fc7a0612775390155 100644 (file)
@@ -12,7 +12,7 @@ m4/intl-thread-locale.m4
 m4/musl.m4
 
 Depends-on:
-c-strcase
+c-strcasecmp
 c-strcasestr
 setlocale
 thread
index 6e4ab3a4af3299602bd58fe701ebae6646c37044..87de812dc854ab418a6233971137d5b78fbf6e3d 100644 (file)
@@ -14,7 +14,7 @@ mbchar
 mbuiter
 iconv
 localcharset
-c-strcase
+c-strcasecmp
 xstriconv
 xalloc
 gettext-h
index 53f0187238ec68dedffb0e2f26e4e4d9099cfc85..771ea21b611927389a1f4726add2c9ae48d2536b 100644 (file)
@@ -7,7 +7,7 @@ lib/propername.h
 
 Depends-on:
 localcharset
-c-strcase
+c-strcasecmp
 gettext-h
 
 configure.ac:
index 542287dcea5522491d5fc765a3d3e4712cd5c31c..53b4b55ea5813f34c95de682a3fd4d888a2add22 100644 (file)
@@ -10,7 +10,7 @@ iconv
 iconv_open
 free-posix
 strdup
-c-strcase
+c-strcasecmp
 
 configure.ac:
 if test $gl_cond_libtool = false; then
index a55a26d7bf91061b2083b0e7bc1ead05b6380e11..ff746cc95992d70c0ebc5666425880f2b2f19db6 100644 (file)
@@ -17,7 +17,7 @@ unistr/u8-mbtoucr
 unistr/u8-uctomb
 free-posix
 strdup
-c-strcase
+c-strcasecmp
 c-strcaseeq
 memmove
 
index aa58691596118f484f34d2ef1ddd833497a026d5..090855ccc9e6eff1d4f4daf2f7e60752465eeb43 100644 (file)
@@ -11,7 +11,7 @@ bool
 striconveh
 malloca
 strdup
-c-strcase
+c-strcasecmp
 
 configure.ac:
 
diff --git a/tests/test-c-strcasecmp.sh b/tests/test-c-strcasecmp.sh
new file mode 100755 (executable)
index 0000000..8049c7b
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Test in the C locale.
+${CHECKER} ./test-c-strcasecmp${EXEEXT} || exit 1
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: "${LOCALE_FR=fr_FR}"
+if test $LOCALE_FR != none; then
+  LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strcasecmp${EXEEXT} locale || exit 1
+fi
+
+# Test in a Turkish UTF-8 locale.
+: "${LOCALE_TR_UTF8=tr_TR.UTF-8}"
+if test $LOCALE_TR_UTF8 != none; then
+  LC_ALL=$LOCALE_TR_UTF8 ${CHECKER} ./test-c-strcasecmp${EXEEXT} locale || exit 1
+fi
+
+exit 0
similarity index 69%
rename from tests/test-c-strcase.sh
rename to tests/test-c-strncasecmp.sh
index 9f491e0f960a757171bccb9dcb5e115b52e7e7c9..30067d153e7ae308d6a3d6c48a3cade4f7189de3 100755 (executable)
@@ -1,20 +1,17 @@
 #!/bin/sh
 
 # Test in the C locale.
-${CHECKER} ./test-c-strcasecmp${EXEEXT} || exit 1
 ${CHECKER} ./test-c-strncasecmp${EXEEXT} || exit 1
 
 # Test in an ISO-8859-1 or ISO-8859-15 locale.
 : "${LOCALE_FR=fr_FR}"
 if test $LOCALE_FR != none; then
-  LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strcasecmp${EXEEXT} locale || exit 1
   LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strncasecmp${EXEEXT} locale || exit 1
 fi
 
 # Test in a Turkish UTF-8 locale.
 : "${LOCALE_TR_UTF8=tr_TR.UTF-8}"
 if test $LOCALE_TR_UTF8 != none; then
-  LC_ALL=$LOCALE_TR_UTF8 ${CHECKER} ./test-c-strcasecmp${EXEEXT} locale || exit 1
   LC_ALL=$LOCALE_TR_UTF8 ${CHECKER} ./test-c-strncasecmp${EXEEXT} locale || exit 1
 fi