+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.
func_module memset
func_module strcspn
func_module strpbrk
- func_module strstr
func_module strerror
func_module mktime
func_end_table
func_module hard-locale
func_module mbschr
func_module mbsrchr
+ func_module mbsstr
func_module mbswidth
func_module memcasecmp
func_module memcoll
# 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:
# 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
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
}
--- /dev/null
+# 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])
+ :
+])
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])
])
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])
])
+++ /dev/null
-# 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])
- :
-])
--- /dev/null
+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
+
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' \
-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' \
-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
+++ /dev/null
-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