Yoann Vandoorselaere wrote: > Attached is a patch for the strcasestr module to use generated string.h.
Thanks. > +#if @REPLACE_STRCASESTR Please say so if the patch is untested. It's not dishonoring to propose an untested patch; just a warning for us that we need to read it more carefully and that we need to test it. I'm committing the following, complete (and tested) patch. 2007-01-27 Yoann Vandoorselaere <[EMAIL PROTECTED]> Bruno Haible <[EMAIL PROTECTED]> * 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. *** lib/strcasestr.c 14 Sep 2006 14:18:36 -0000 1.4 --- lib/strcasestr.c 27 Jan 2007 13:00:39 -0000 *************** *** 1,5 **** /* Case-insensitive searching in a string. ! Copyright (C) 2005-2006 Free Software Foundation, Inc. Written by Bruno Haible <[EMAIL PROTECTED]>, 2005. This program is free software; you can redistribute it and/or modify --- 1,5 ---- /* Case-insensitive searching in a string. ! Copyright (C) 2005-2007 Free Software Foundation, Inc. Written by Bruno Haible <[EMAIL PROTECTED]>, 2005. This program is free software; you can redistribute it and/or modify *************** *** 19,28 **** #include <config.h> /* Specification. */ ! #include "strcasestr.h" #include <ctype.h> ! #include <stddef.h> /* for NULL */ #if HAVE_MBRTOWC # include "mbuiter.h" --- 19,28 ---- #include <config.h> /* Specification. */ ! #include <string.h> #include <ctype.h> ! #include <stddef.h> /* for NULL, in case a nonstandard string.h lacks it */ #if HAVE_MBRTOWC # include "mbuiter.h" *** lib/string_.h 27 Jan 2007 12:58:57 -0000 1.2 --- lib/string_.h 27 Jan 2007 13:00:39 -0000 *************** *** 138,143 **** --- 138,153 ---- 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: *** m4/strcasestr.m4 26 Sep 2005 13:58:51 -0000 1.2 --- m4/strcasestr.m4 27 Jan 2007 13:00:40 -0000 *************** *** 1,5 **** ! # strcasestr.m4 serial 2 ! 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, dnl with or without modifications, as long as this notice is preserved. --- 1,5 ---- ! # 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,15 **** 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 ]) --- 9,15 ---- dnl No known system has a strcasestr() function that works correctly in dnl multibyte locales. Therefore we use our version always. AC_LIBOBJ(strcasestr) ! REPLACE_STRCASESTR=1 gl_PREREQ_STRCASESTR ]) *** m4/string_h.m4 26 Jan 2007 22:16:55 -0000 1.1 --- m4/string_h.m4 27 Jan 2007 13:00:40 -0000 *************** *** 38,41 **** --- 38,42 ---- 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]) ]) *** modules/strcasestr 13 Oct 2006 12:40:23 -0000 1.3 --- modules/strcasestr 27 Jan 2007 13:00:40 -0000 *************** *** 2,14 **** 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 configure.ac: gl_FUNC_STRCASESTR --- 2,14 ---- strcasestr() function: case-insensitive search for a substring in a string. Files: lib/strcasestr.c m4/strcasestr.m4 m4/mbrtowc.m4 Depends-on: mbuiter + string configure.ac: gl_FUNC_STRCASESTR *************** *** 16,22 **** Makefile.am: Include: ! "strcasestr.h" License: LGPL --- 16,22 ---- Makefile.am: Include: ! <string.h> License: LGPL *** modules/string 26 Jan 2007 22:16:55 -0000 1.1 --- modules/string 27 Jan 2007 13:00:40 -0000 *************** *** 37,42 **** --- 37,43 ---- -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] $@