[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
new module mbsstr, remove module strstr
From: |
Bruno Haible |
Subject: |
new module mbsstr, remove module strstr |
Date: |
Mon, 5 Feb 2007 02:40:52 +0100 |
User-agent: |
KMail/1.5.4 |
This introduces a new module mbsstr. mbsstr() is like strstr(), except it
works on character strings (i.e. on multibyte strings). The module strstr
is no longer needed, since no platforms are known that don't have strstr().
2007-02-04 Bruno Haible <address@hidden>
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.
============================ modules/mbsstr ==================================
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
============================ m4/mbsstr.m4 ====================================
# 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])
:
])
==============================================================================
--- MODULES.html.sh 5 Feb 2007 01:16:13 -0000 1.182
+++ MODULES.html.sh 5 Feb 2007 01:31:52 -0000
@@ -1502,7 +1502,6 @@
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_module hard-locale
func_module mbschr
func_module mbsrchr
+ func_module mbsstr
func_module mbswidth
func_module memcasecmp
func_module memcoll
--- lib/mbsstr.c 5 Feb 2007 01:19:02 -0000 1.1
+++ lib/mbsstr.c 5 Feb 2007 01:31:52 -0000
@@ -27,9 +27,10 @@
# 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:
--- lib/string_.h 5 Feb 2007 01:16:13 -0000 1.9
+++ lib/string_.h 5 Feb 2007 01:31:52 -0000
@@ -247,20 +247,14 @@
# 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 * 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
}
--- m4/string_h.m4 5 Feb 2007 01:16:13 -0000 1.7
+++ m4/string_h.m4 5 Feb 2007 01:31:53 -0000
@@ -42,7 +42,6 @@
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 @@
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])
])
--- modules/string 5 Feb 2007 01:16:13 -0000 1.6
+++ modules/string 5 Feb 2007 01:31:53 -0000
@@ -23,6 +23,7 @@
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 @@
-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 @@
-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; \
} > address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- new module mbsstr, remove module strstr,
Bruno Haible <=