Le samedi 27 janvier 2007 à 10:52 +0100, Yoann Vandoorselaere a écrit :
> Le vendredi 26 janvier 2007 à 00:03 -0800, Paul Eggert a écrit :
> > I'd like to add a 'string' module to gnulib, which does for <string.h>
> > what the sys_time module does for <sys/time.h>, namely, sets up a
> > substitute string.h that has needed GNU declarations.  That way,
> > we don't need to worry about the little include files like "strstr.h"
> > which make the rest of the code harder to read and maintain.
> 
> Attached is a patch for the strcasestr module to use generated string.h.

The previous patch was broken, here is an updated version.

-- 
Yoann Vandoorselaere | Responsable R&D / CTO | PreludeIDS Technologies
Tel: +33 (0)8 70 70 21 58                  Fax: +33(0)4 78 42 21 58
http://www.prelude-ids.com
Index: lib/string_.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/string_.h,v
retrieving revision 1.1
diff -u -r1.1 string_.h
--- lib/string_.h	26 Jan 2007 22:16:55 -0000	1.1
+++ lib/string_.h	27 Jan 2007 13:53:38 -0000
@@ -137,6 +137,16 @@
 char *strstr (char const *__haystack, char const *__needle);
 #endif
 
+/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
+   comparison.
+   Note: This function may, in multibyte locales, return success even if
+   strlen (haystack) < strlen (needle) !  */
+#if @REPLACE_STRCASESTR@
+# undef strcasestr
+# define strcasestr rpl_strcasestr
+extern char *strcasestr (const char *haystack, const char *needle);
+#endif
+
 /* Parse S into tokens separated by characters in DELIM.
    If S is NULL, the saved pointer in SAVE_PTR is used as
    the next starting point.  For example:
Index: m4/string_h.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/string_h.m4,v
retrieving revision 1.1
diff -u -r1.1 string_h.m4
--- m4/string_h.m4	26 Jan 2007 22:16:55 -0000	1.1
+++ m4/string_h.m4	27 Jan 2007 13:53:38 -0000
@@ -38,4 +38,5 @@
   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])
 ])
Index: m4/strcasestr.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/strcasestr.m4,v
retrieving revision 1.2
diff -u -r1.2 strcasestr.m4
--- m4/strcasestr.m4	26 Sep 2005 13:58:51 -0000	1.2
+++ m4/strcasestr.m4	27 Jan 2007 13:53:38 -0000
@@ -1,4 +1,4 @@
-# strcasestr.m4 serial 2
+# strcasestr.m4 serial 3
 dnl Copyright (C) 2005 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,8 +9,8 @@
   dnl No known system has a strcasestr() function that works correctly in
   dnl multibyte locales. Therefore we use our version always.
   AC_LIBOBJ(strcasestr)
-  AC_DEFINE(strcasestr, rpl_strcasestr, [Define to rpl_strcasestr always.])
   gl_PREREQ_STRCASESTR
+  REPLACE_STRCASESTR=1
 ])
 
 # Prerequisites of lib/strcasestr.c.
Index: modules/strcasestr
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/strcasestr,v
retrieving revision 1.3
diff -u -r1.3 strcasestr
--- modules/strcasestr	13 Oct 2006 12:40:23 -0000	1.3
+++ modules/strcasestr	27 Jan 2007 13:53:38 -0000
@@ -2,7 +2,6 @@
 strcasestr() function: case-insensitive search for a substring in a string.
 
 Files:
-lib/strcasestr.h
 lib/strcasestr.c
 m4/strcasestr.m4
 m4/mbrtowc.m4
@@ -16,7 +15,7 @@
 Makefile.am:
 
 Include:
-"strcasestr.h"
+<string.h>
 
 License:
 LGPL
Index: modules/string
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/string,v
retrieving revision 1.1
diff -u -r1.1 string
--- modules/string	26 Jan 2007 22:16:55 -0000	1.1
+++ modules/string	27 Jan 2007 13:53:38 -0000
@@ -37,6 +37,7 @@
 	      -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; \
 	} > [EMAIL PROTECTED]
 	mv [EMAIL PROTECTED] $@

Reply via email to