Declare strcasestr() in the <string.h> replacement, rather than in
authorBruno Haible <bruno@clisp.org>
Sat, 27 Jan 2007 13:17:15 +0000 (13:17 +0000)
committerBruno Haible <bruno@clisp.org>
Sat, 27 Jan 2007 13:17:15 +0000 (13:17 +0000)
strcasestr.h.

ChangeLog
lib/strcasestr.c
lib/string_.h
m4/strcasestr.m4
m4/string_h.m4
modules/strcasestr
modules/string

index 5bec53c0506e22e2c86534f7f7391d8b175e1f89..cf7107dc49eb2c363660203fcb60c27f4c76bd58 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2007-01-27  Yoann Vandoorselaere <yoann.v@prelude-ids.com>
+            Bruno Haible  <bruno@clisp.org>
+
+       * modules/strcasestr (Files): Remove lib/strcasestr.h.
+       (Depends-on): Add string.
+       (Includes): Use <string.h> instead of strcasestr.h.
+       * modules/string (Makefile.am): Also substitute the value of
+       REPLACE_STRCASESTR.
+       * m4/strcasestr.m4 (gl_FUNC_STRCASESTR): Don't define strcasestr here;
+       assume strcasestr is declared in <string.h> not <strings.h>. Also
+       set REPLACE_STRCASESTR.
+       * m4/string_h.m4 (gl_HEADER_STRING_H_BODY): Provide a default value for
+       REPLACE_STRCASESTR.
+       * lib/strcasestr.h: Remove file.
+       * lib/strcasestr.c: Include <string.h> instead of strcasestr.h.
+       * lib/string_.h (strcasestr): New declaration.
+
 2007-01-27  Bruno Haible  <bruno@clisp.org>
 
        * lib/string_.h: Use 'extern'.
index 6812b5de88187a5de254737b22a985d140efc265..0a25f86f6b722cc3bc741f267d8bb4d1eaf64e54 100644 (file)
@@ -1,5 +1,5 @@
 /* Case-insensitive searching in a string.
-   Copyright (C) 2005-2006 Free Software Foundation, Inc.
+   Copyright (C) 2005-2007 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2005.
 
    This program is free software; you can redistribute it and/or modify
 #include <config.h>
 
 /* Specification.  */
-#include "strcasestr.h"
+#include <string.h>
 
 #include <ctype.h>
-#include <stddef.h>  /* for NULL */
+#include <stddef.h>  /* for NULL, in case a nonstandard string.h lacks it */
 
 #if HAVE_MBRTOWC
 # include "mbuiter.h"
index 326d5da652fea35d5c86a4f17c4a467ff5472bf6..94d991cf06ec2c06bb205f799fb147d6f5602751 100644 (file)
@@ -138,6 +138,16 @@ extern char *strsep (char **restrict __stringp, char const *restrict __delim);
 extern 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 ae83c481d791fcbaeccf8677c9c8d2799a89a0a7..92a0f1554cad339613b22fb59ab5e7f94824b70e 100644 (file)
@@ -1,5 +1,5 @@
-# strcasestr.m4 serial 2
-dnl Copyright (C) 2005 Free Software Foundation, Inc.
+# strcasestr.m4 serial 3
+dnl Copyright (C) 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.
@@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_STRCASESTR],
   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.])
+  REPLACE_STRCASESTR=1
   gl_PREREQ_STRCASESTR
 ])
 
index 91e5c67728e301ac4e5f2c1fed83e32f693604b0..9fbdffdde2590491ce1881d2dd32d1806c6d770b 100644 (file)
@@ -38,4 +38,5 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
   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 016a26bfa2e052b2ecf61f1bfdd0d34de3d2c077..ed7dea72da879e930a70f4dbc5ee6dd6c6435b0d 100644 (file)
@@ -2,13 +2,13 @@ Description:
 strcasestr() function: case-insensitive search for a substring in a string.
 
 Files:
-lib/strcasestr.h
 lib/strcasestr.c
 m4/strcasestr.m4
 m4/mbrtowc.m4
 
 Depends-on:
 mbuiter
+string
 
 configure.ac:
 gl_FUNC_STRCASESTR
@@ -16,7 +16,7 @@ gl_FUNC_STRCASESTR
 Makefile.am:
 
 Include:
-"strcasestr.h"
+<string.h>
 
 License:
 LGPL
index 54a5498e2cd03c7ec5c1be5eb1c2ab9659e36c2c..313613f1820284c65b3672d63e6e4efd163ed16d 100644 (file)
@@ -37,6 +37,7 @@ string.h: string_.h
              -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
        mv $@-t $@