Simplify handling of strncasecmp. Improve link warning.
authorBruno Haible <bruno@clisp.org>
Mon, 5 Feb 2007 02:15:46 +0000 (02:15 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 5 Feb 2007 02:15:46 +0000 (02:15 +0000)
ChangeLog
lib/string_.h
m4/string_h.m4
modules/strcase
modules/string

index 68d8616..6f50e0e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2007-02-04  Bruno Haible  <bruno@clisp.org>
 
+       Simplify handling of strncasecmp.
+       * lib/string_.h (strncasecmp): Remove test for GNULIB_STRCASE. Change
+       the conditional link warning.
+       * m4/string_h.m4 (gl_STRING_MODULE_INDICATOR_DEFAULTS): Don't
+       initialize GNULIB_STRCASE.
+       * modules/strcase (configure.ac): Don't invoke
+       gl_STRING_MODULE_INDICATOR.
+       * modules/string (string.h): Don't substitute GNULIB_STRCASE.
+
+2007-02-04  Bruno Haible  <bruno@clisp.org>
+
        New module mbscasecmp, reduced goal of strcasecmp.
        * modules/mbscasecmp: New file.
        * lib/mbscasecmp.c: New file, copied from lib/strcasecmp.c.
index 59a14ca..e1c0373 100644 (file)
@@ -133,15 +133,16 @@ extern int strcasecmp (char const *s1, char const *s2);
    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 @GNULIB_STRCASE@
-# if ! @HAVE_DECL_STRNCASECMP@
-extern int strncasecmp (char const *__s1, char const *__s2, size_t __n);
-# endif
+#if ! @HAVE_DECL_STRNCASECMP@
+extern int strncasecmp (char const *s1, char const *s2, size_t n);
 #endif
 #if 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.  */
 # undef strncasecmp
 # define strncasecmp(a,b) \
-    (GL_LINK_WARNING ("strncasecmp cannot work correctly in multibyte locales - don't use it if you care about internationalization"), \
+    (GL_LINK_WARNING ("strncasecmp cannot work correctly on character strings in multibyte locales - don't use it if you care about internationalization; use c_strncasecmp (from gnulib module c-strcase) if you want a locale independent function"), \
      strncasecmp (a, b))
 #endif
 
index 8dfe95f..b68afc9 100644 (file)
@@ -59,7 +59,6 @@ AC_DEFUN([gl_STRING_MODULE_INDICATOR_DEFAULTS],
   GNULIB_MEMRCHR=0;     AC_SUBST([GNULIB_MEMRCHR])
   GNULIB_STPCPY=0;      AC_SUBST([GNULIB_STPCPY])
   GNULIB_STPNCPY=0;     AC_SUBST([GNULIB_STPNCPY])
-  GNULIB_STRCASE=0;     AC_SUBST([GNULIB_STRCASE])
   GNULIB_STRCHRNUL=0;   AC_SUBST([GNULIB_STRCHRNUL])
   GNULIB_STRDUP=0;      AC_SUBST([GNULIB_STRDUP])
   GNULIB_STRNDUP=0;     AC_SUBST([GNULIB_STRNDUP])
index 77d2f2c..05c1c92 100644 (file)
@@ -13,7 +13,6 @@ string
 
 configure.ac:
 gl_STRCASE
-gl_STRING_MODULE_INDICATOR([strcase])
 
 Makefile.am:
 
index 8e65725..a2eab98 100644 (file)
@@ -30,7 +30,6 @@ string.h: string_.h
              -e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \
              -e 's|@''GNULIB_STPCPY''@|$(GNULIB_STPCPY)|g' \
              -e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \
-             -e 's|@''GNULIB_STRCASE''@|$(GNULIB_STRCASE)|g' \
              -e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \
              -e 's|@''GNULIB_STRDUP''@|$(GNULIB_STRDUP)|g' \
              -e 's|@''GNULIB_STRNDUP''@|$(GNULIB_STRNDUP)|g' \