mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2026-10-24 00:48:56 +03:00
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.
This commit is contained in:
31
ChangeLog
31
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.
|
||||
|
||||
@@ -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
|
||||
|
||||
29
doc/c-strcasecmp.texi
Normal file
29
doc/c-strcasecmp.texi
Normal file
@@ -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}.
|
||||
@@ -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}.
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
23
modules/c-strcasecmp
Normal file
23
modules/c-strcasecmp
Normal file
@@ -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
|
||||
21
modules/c-strcasecmp-tests
Normal file
21
modules/c-strcasecmp-tests
Normal file
@@ -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)
|
||||
@@ -5,7 +5,7 @@ Files:
|
||||
lib/c-strcaseeq.h
|
||||
|
||||
Depends-on:
|
||||
c-strcase
|
||||
c-strcasecmp
|
||||
c-ctype
|
||||
|
||||
configure.ac:
|
||||
|
||||
@@ -8,7 +8,7 @@ lib/str-two-way.h
|
||||
|
||||
Depends-on:
|
||||
c-ctype
|
||||
c-strcase
|
||||
c-strncasecmp
|
||||
bool
|
||||
memchr
|
||||
memcmp
|
||||
|
||||
23
modules/c-strncasecmp
Normal file
23
modules/c-strncasecmp
Normal file
@@ -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
|
||||
@@ -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)
|
||||
@@ -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]
|
||||
|
||||
@@ -12,7 +12,7 @@ m4/intl-thread-locale.m4
|
||||
m4/musl.m4
|
||||
|
||||
Depends-on:
|
||||
c-strcase
|
||||
c-strcasecmp
|
||||
c-strcasestr
|
||||
setlocale
|
||||
thread
|
||||
|
||||
@@ -14,7 +14,7 @@ mbchar
|
||||
mbuiter
|
||||
iconv
|
||||
localcharset
|
||||
c-strcase
|
||||
c-strcasecmp
|
||||
xstriconv
|
||||
xalloc
|
||||
gettext-h
|
||||
|
||||
@@ -7,7 +7,7 @@ lib/propername.h
|
||||
|
||||
Depends-on:
|
||||
localcharset
|
||||
c-strcase
|
||||
c-strcasecmp
|
||||
gettext-h
|
||||
|
||||
configure.ac:
|
||||
|
||||
@@ -10,7 +10,7 @@ iconv
|
||||
iconv_open
|
||||
free-posix
|
||||
strdup
|
||||
c-strcase
|
||||
c-strcasecmp
|
||||
|
||||
configure.ac:
|
||||
if test $gl_cond_libtool = false; then
|
||||
|
||||
@@ -17,7 +17,7 @@ unistr/u8-mbtoucr
|
||||
unistr/u8-uctomb
|
||||
free-posix
|
||||
strdup
|
||||
c-strcase
|
||||
c-strcasecmp
|
||||
c-strcaseeq
|
||||
memmove
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ bool
|
||||
striconveh
|
||||
malloca
|
||||
strdup
|
||||
c-strcase
|
||||
c-strcasecmp
|
||||
|
||||
configure.ac:
|
||||
|
||||
|
||||
18
tests/test-c-strcasecmp.sh
Executable file
18
tests/test-c-strcasecmp.sh
Executable file
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user