* modules/strstr: Split into...
* modules/strstr-simple: ...new module that does not care about
performance, but does care about glibc bug.
* m4/strstr.m4 (gl_FUNC_STRSTR): Split...
(gl_FUNC_STRSTR_SIMPLE): ...into new macro, which replaces strstr
if platform memchr is broken, per Debian bug 521737.
* m4/strcasestr.m4 (gl_FUNC_STRCASESTR_SIMPLE): React to broken
memchr.
* m4/memchr.m4 (gl_FUNC_MEMCHR): Only expand once.
* doc/posix-functions/strstr.texi (strstr): Document the fix.
* doc/glibc-functions/strcasestr.texi (strcasestr): Likewise.
* modules/mountlist (Depends-on): Add strstr-simple.
* modules/gen-uni-tables (Depends-on): Likewise.
* modules/argz (Depends-on): Add strstr.
Signed-off-by: Eric Blake <ebb9@byu.net>
+2009-06-17 Eric Blake <ebb9@byu.net>
+
+ strstr, strcasestr: replace on platforms with broken memchr
+ * modules/strstr: Split into...
+ * modules/strstr-simple: ...new module that does not care about
+ performance, but does care about glibc bug.
+ * m4/strstr.m4 (gl_FUNC_STRSTR): Split...
+ (gl_FUNC_STRSTR_SIMPLE): ...into new macro, which replaces strstr
+ if platform memchr is broken, per Debian bug 521737.
+ * m4/strcasestr.m4 (gl_FUNC_STRCASESTR_SIMPLE): React to broken
+ memchr.
+ * m4/memchr.m4 (gl_FUNC_MEMCHR): Only expand once.
+ * doc/posix-functions/strstr.texi (strstr): Document the fix.
+ * doc/glibc-functions/strcasestr.texi (strcasestr): Likewise.
+ * modules/mountlist (Depends-on): Add strstr-simple.
+ * modules/gen-uni-tables (Depends-on): Likewise.
+ * modules/argz (Depends-on): Add strstr.
+
2009-06-17 Bruno Haible <bruno@clisp.org>
* modules/posix_spawn-internal (Depends-on): Add errno.
@itemize
@item
This function is missing on some platforms:
-AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, BeOS.
+AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x,
+mingw, BeOS.
+
+@item
+This function can trigger memchr bugs on some platforms:
+glibc 2.10.
@end itemize
Portability problems fixed by Gnulib module @code{strcasestr}:
POSIX specification: @url{http://www.opengroup.org/onlinepubs/9699919799/functions/strstr.html}
-Gnulib module: strstr
+Gnulib module: strstr or strstr-simple
-Portability problems fixed by Gnulib:
+Portability problems fixed by either Gnulib module @code{strstr-simple}
+or @code{strstr}:
+@itemize
+@item
+This function can trigger memchr bugs on some platforms:
+glibc 2.10.
+@end itemize
+
+Portability problems fixed by Gnulib @code{strstr}:
@itemize
@item
This function has quadratic instead of linear worst-case complexity on some
platforms:
-glibc 2.8, MacOS X 10.3, FreeBSD 6.2, NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw.
+glibc 2.8, MacOS X 10.3, FreeBSD 6.2, NetBSD 3.0, OpenBSD 4.0, AIX
+5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw.
@end itemize
Portability problems not fixed by Gnulib:
-# memchr.m4 serial 6
+# memchr.m4 serial 7
dnl Copyright (C) 2002, 2003, 2004, 2009 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_MEMCHR],
+AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
[
dnl Check for prerequisites for memory fence checks.
gl_FUNC_MMAP_ANON
-# strcasestr.m4 serial 12
-dnl Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
+# strcasestr.m4 serial 13
+dnl Copyright (C) 2005, 2007, 2008, 2009 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.
-dnl Check that strcasestr is present.
+dnl Check that strcasestr is present and works.
AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
[
dnl Persuade glibc <string.h> to declare strcasestr().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_REQUIRE([gl_FUNC_MEMCHR])
AC_REPLACE_FUNCS([strcasestr])
if test $ac_cv_func_strcasestr = no; then
HAVE_STRCASESTR=0
gl_PREREQ_STRCASESTR
+ elif test "$gl_cv_func_memchr_works" != yes; then
+ REPLACE_STRCASESTR=1
+ AC_LIBOBJ([strcasestr])
+ gl_PREREQ_STRCASESTR
fi
]) # gl_FUNC_STRCASESTR_SIMPLE
-# strstr.m4 serial 5
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+# strstr.m4 serial 6
+dnl Copyright (C) 2008, 2009 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.
-dnl Check that strstr is efficient.
-AC_DEFUN([gl_FUNC_STRSTR],
+dnl Check that strstr works.
+AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
[
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_REQUIRE([gl_FUNC_MEMCHR])
+ if test "$gl_cv_func_memchr_works" != yes; then
+ REPLACE_STRSTR=1
+ AC_LIBOBJ([strstr])
+ fi
+]) # gl_FUNC_STRSTR_SIMPLE
+
+dnl Additionally, check that strstr is efficient.
+AC_DEFUN([gl_FUNC_STRSTR],
+[
+ AC_REQUIRE([gl_FUNC_STRSTR_SIMPLE])
AC_CACHE_CHECK([whether strstr works in linear time],
[gl_cv_func_strstr_linear],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
stpcpy
strndup
strnlen
+strstr
configure.ac:
gl_FUNC_ARGZ
Depends-on:
memcmp
strdup
+strstr-simple
configure.ac:
Depends-on:
stdbool
stdint
+strstr-simple
xalloc
configure.ac:
strstr() function: efficiently locate first substring in a buffer.
Files:
-lib/str-two-way.h
-lib/strstr.c
-m4/strstr.m4
Depends-on:
-string
-stdbool
-memchr
-memcmp
+strstr-simple
configure.ac:
gl_FUNC_STRSTR
-gl_STRING_MODULE_INDICATOR([strstr])
Makefile.am:
--- /dev/null
+Description:
+strstr() function: locate first substring in a buffer.
+
+Files:
+lib/str-two-way.h
+lib/strstr.c
+m4/strstr.m4
+
+Depends-on:
+string
+stdbool
+memchr
+memcmp
+
+configure.ac:
+gl_FUNC_STRSTR_SIMPLE
+gl_STRING_MODULE_INDICATOR([strstr])
+
+Makefile.am:
+
+Include:
+<string.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all, Eric Blake