New module 'mbsstr'. Remove module 'strstr'.
authorBruno Haible <bruno@clisp.org>
Mon, 5 Feb 2007 01:36:34 +0000 (01:36 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 5 Feb 2007 01:36:34 +0000 (01:36 +0000)
ChangeLog
MODULES.html.sh
lib/mbsstr.c
lib/string_.h
m4/mbsstr.m4 [new file with mode: 0644]
m4/string_h.m4
m4/strstr.m4 [deleted file]
modules/mbsstr [new file with mode: 0644]
modules/string
modules/strstr [deleted file]

index 9c8f82f..7edacf8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
 2007-02-04  Bruno Haible  <bruno@clisp.org>
 
+       New module mbsstr. Remove module strstr.
+       * modules/mbsstr: New file.
+       * modules/strstr: Remove file.
+       * lib/mbsstr.c: Renamed from lib/strstr.c.
+       (mbsstr): Renamed from strstr.
+       * lib/string_.h (strstr): Remove declaration. Change the conditional
+       link warning.
+       (mbsstr): New declaration.
+       * m4/mbsstr.m4: New file.
+       * m4/strstr.m4: Remove file.
+       * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Don't initialize
+       REPLACE_STRSTR.
+       (gl_STRING_MODULE_INDICATOR_DEFAULTS): Initialize GNULIB_MBSSTR.
+       Don't initialize GNULIB_STRSTR.
+       * modules/string (string.h): Also substitute GNULIB_MBSSTR. Don't
+       substitute GNULIB_STRSTR and REPLACE_STRSTR.
+       * MODULES.html.sh (Internationalization functions): Add mbsstr.
+       (Support for systems lacking ANSI C 89): Remove strstr.
+
+2007-02-04  Bruno Haible  <bruno@clisp.org>
+
        New module mbsrchr.
        * modules/mbsrchr: New file.
        * lib/mbsrchr.c: New file.
index 303f8a4..b11f90f 100755 (executable)
@@ -1502,7 +1502,6 @@ func_all_modules ()
   func_module memset
   func_module strcspn
   func_module strpbrk
-  func_module strstr
   func_module strerror
   func_module mktime
   func_end_table
@@ -2163,6 +2162,7 @@ func_all_modules ()
   func_module hard-locale
   func_module mbschr
   func_module mbsrchr
+  func_module mbsstr
   func_module mbswidth
   func_module memcasecmp
   func_module memcoll
index 2ee1650..84b8289 100644 (file)
 # include "mbuiter.h"
 #endif
 
-/* Find the first occurrence of NEEDLE in HAYSTACK.  */
+/* Find the first occurrence of the character string NEEDLE in the character
+   string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.  */
 char *
-strstr (const char *haystack, const char *needle)
+mbsstr (const char *haystack, const char *needle)
 {
   /* Be careful not to look at the entire extent of haystack or needle
      until needed.  This is useful because of these two cases:
index 36d4d05..6b99fb2 100644 (file)
@@ -247,20 +247,14 @@ extern char *strsep (char **restrict __stringp, char const *restrict __delim);
 # define strsep strsep_is_unportable__use_gnulib_module_strsep_for_portability
 #endif
 
-/* Find the first occurrence of NEEDLE in HAYSTACK.
-   No known system has a strstr() function that works correctly in
-   multibyte locales.  Therefore use our version always, if the strstr
-   module is available.  */
-#if @GNULIB_STRSTR@
-# if @REPLACE_STRSTR@
-#  undef strstr
-#  define strstr rpl_strstr
-extern char *strstr (char const *__haystack, char const *__needle);
-# endif
-#elif defined GNULIB_POSIXCHECK
+#if defined GNULIB_POSIXCHECK
+/* strstr() does not work with multibyte strings if the locale encoding is
+   different from UTF-8:
+   POSIX says that it operates on "strings", and "string" in POSIX is defined
+   as a sequence of bytes, not of characters.  */
 # undef strstr
 # define strstr(a,b) \
-    (GL_LINK_WARNING ("strstr is often incorrectly implemented for multibyte locales - use gnulib module 'strstr' for correct and portable internationalization"), \
+    (GL_LINK_WARNING ("strstr cannot work correctly on character strings in most multibyte locales - use mbsstr if you care about internationalization"), \
      strstr (a, b))
 #endif
 
@@ -335,6 +329,14 @@ extern char * mbschr (const char *string, int c);
 extern char * mbsrchr (const char *string, int c);
 #endif
 
+#if @GNULIB_MBSSTR@
+/* Find the first occurrence of the character string NEEDLE in the character
+   string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
+   Unlike strstr(), this function works correctly in multibyte locales with
+   encodings different from UTF-8.  */
+extern char * mbsstr (const char *haystack, const char *needle);
+#endif
+
 
 #ifdef __cplusplus
 }
diff --git a/m4/mbsstr.m4 b/m4/mbsstr.m4
new file mode 100644 (file)
index 0000000..cec117f
--- /dev/null
@@ -0,0 +1,16 @@
+# mbsstr.m4 serial 1
+dnl Copyright (C) 2007 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MBSSTR],
+[
+  gl_PREREQ_MBSSTR
+])
+
+# Prerequisites of lib/mbsstr.c.
+AC_DEFUN([gl_PREREQ_MBSSTR], [
+  AC_REQUIRE([gl_FUNC_MBRTOWC])
+  :
+])
index bb0e752..152a6ad 100644 (file)
@@ -42,7 +42,6 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
   HAVE_STRSEP=1;               AC_SUBST([HAVE_STRSEP])
   HAVE_DECL_STRTOK_R=1;                AC_SUBST([HAVE_DECL_STRTOK_R])
   REPLACE_STRCASECMP=0;                AC_SUBST([REPLACE_STRCASECMP])
-  REPLACE_STRSTR=0;            AC_SUBST([REPLACE_STRSTR])
   REPLACE_STRCASESTR=0;                AC_SUBST([REPLACE_STRCASESTR])
 ])
 
@@ -67,9 +66,9 @@ AC_DEFUN([gl_STRING_MODULE_INDICATOR_DEFAULTS],
   GNULIB_STRNLEN=0;     AC_SUBST([GNULIB_STRNLEN])
   GNULIB_STRPBRK=0;     AC_SUBST([GNULIB_STRPBRK])
   GNULIB_STRSEP=0;      AC_SUBST([GNULIB_STRSEP])
-  GNULIB_STRSTR=0;      AC_SUBST([GNULIB_STRSTR])
   GNULIB_STRCASESTR=0;  AC_SUBST([GNULIB_STRCASESTR])
   GNULIB_STRTOK_R=0;    AC_SUBST([GNULIB_STRTOK_R])
   GNULIB_MBSCHR=0;      AC_SUBST([GNULIB_MBSCHR])
   GNULIB_MBSRCHR=0;     AC_SUBST([GNULIB_MBSRCHR])
+  GNULIB_MBSSTR=0;      AC_SUBST([GNULIB_MBSSTR])
 ])
diff --git a/m4/strstr.m4 b/m4/strstr.m4
deleted file mode 100644 (file)
index 97eb0a8..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# strstr.m4 serial 6
-dnl Copyright (C) 2002-2003, 2005, 2007 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([gl_FUNC_STRSTR],
-[
-  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
-  dnl No known system has a strstr() function that works correctly in
-  dnl multibyte locales. Therefore we use our version always.
-  AC_LIBOBJ(strstr)
-  REPLACE_STRSTR=1
-  gl_PREREQ_STRSTR
-])
-
-# Prerequisites of lib/strstr.c.
-AC_DEFUN([gl_PREREQ_STRSTR], [
-  AC_REQUIRE([gl_FUNC_MBRTOWC])
-  :
-])
diff --git a/modules/mbsstr b/modules/mbsstr
new file mode 100644 (file)
index 0000000..bfcd47a
--- /dev/null
@@ -0,0 +1,28 @@
+Description:
+mbsstr() function: search for a substring in a string.
+
+Files:
+lib/mbsstr.c
+m4/mbsstr.m4
+m4/mbrtowc.m4
+
+Depends-on:
+mbuiter
+string
+
+configure.ac:
+gl_FUNC_MBSSTR
+gl_STRING_MODULE_INDICATOR([mbsstr])
+
+Makefile.am:
+lib_SOURCES += mbsstr.c
+
+Include:
+<string.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
index 764496a..3eac829 100644 (file)
@@ -23,6 +23,7 @@ string.h: string_.h
          sed -e 's|@''ABSOLUTE_STRING_H''@|$(ABSOLUTE_STRING_H)|g' \
              -e 's|@''GNULIB_MBSCHR''@|$(GNULIB_MBSCHR)|g' \
              -e 's|@''GNULIB_MBSRCHR''@|$(GNULIB_MBSRCHR)|g' \
+             -e 's|@''GNULIB_MBSSTR''@|$(GNULIB_MBSSTR)|g' \
              -e 's|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \
              -e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \
              -e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \
@@ -35,7 +36,6 @@ string.h: string_.h
              -e 's|@''GNULIB_STRNLEN''@|$(GNULIB_STRNLEN)|g' \
              -e 's|@''GNULIB_STRPBRK''@|$(GNULIB_STRPBRK)|g' \
              -e 's|@''GNULIB_STRSEP''@|$(GNULIB_STRSEP)|g' \
-             -e 's|@''GNULIB_STRSTR''@|$(GNULIB_STRSTR)|g' \
              -e 's|@''GNULIB_STRCASESTR''@|$(GNULIB_STRCASESTR)|g' \
              -e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|g' \
              -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
@@ -53,7 +53,6 @@ string.h: string_.h
              -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
              -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
              -e 's|@''REPLACE_STRCASECMP''@|$(REPLACE_STRCASECMP)|g' \
-             -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
              -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
              < $(srcdir)/string_.h; \
        } > $@-t
diff --git a/modules/strstr b/modules/strstr
deleted file mode 100644 (file)
index 5e3f9fd..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-Description:
-strstr() function: search for a substring in a string.
-
-Files:
-lib/strstr.c
-m4/strstr.m4
-m4/mbrtowc.m4
-
-Depends-on:
-mbuiter
-string
-
-configure.ac:
-gl_FUNC_STRSTR
-gl_STRING_MODULE_INDICATOR([strstr])
-
-Makefile.am:
-
-Include:
-<string.h>
-
-License:
-LGPL
-
-Maintainer:
-Bruno Haible, glibc