[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strstr
From: |
Eric Blake |
Subject: |
Re: strstr |
Date: |
Wed, 17 Jun 2009 07:26:05 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Bruno Haible on 6/17/2009 2:17 AM:
> Eric Blake wrote:
>> Hmm. I'm now starting to wonder whether I should create a new module
>> strstr-simple, which fixes broken strstr (in the presence of broken
>> memchr) but without worrying about quadratic vs. linear (similar to
>> strcasestr-simple which only worries about providing strcasestr on
>> platforms that lack it, compared to strcasestr which worries about speed).
>
> Would make sense, for consistency with 'strcasestr'.
Done:
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAko47u0ACgkQ84KuGfSFAYAs2QCdEeLdcdd1il1UmpjtA4seo8Z0
oukAn37mhtabGI0p5sf1XUvadbgQf2YD
=FVEY
-----END PGP SIGNATURE-----
>From e3e47d1710f6154c54b65c5d9dd5d56516a893d6 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Tue, 16 Jun 2009 06:14:05 -0600
Subject: [PATCH] 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.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 18 ++++++++++++++++++
doc/glibc-functions/strcasestr.texi | 7 ++++++-
doc/posix-functions/strstr.texi | 15 ++++++++++++---
m4/memchr.m4 | 4 ++--
m4/strcasestr.m4 | 11 ++++++++---
m4/strstr.m4 | 19 +++++++++++++++----
modules/argz | 1 +
modules/gen-uni-tables | 1 +
modules/mountlist | 1 +
modules/strstr | 9 +--------
modules/strstr-simple | 28 ++++++++++++++++++++++++++++
11 files changed, 93 insertions(+), 21 deletions(-)
create mode 100644 modules/strstr-simple
diff --git a/ChangeLog b/ChangeLog
index dc85105..f5c0497 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2009-06-17 Eric Blake <address@hidden>
+
+ 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 <address@hidden>
* modules/posix_spawn-internal (Depends-on): Add errno.
diff --git a/doc/glibc-functions/strcasestr.texi
b/doc/glibc-functions/strcasestr.texi
index feb5104..7ce39f4 100644
--- a/doc/glibc-functions/strcasestr.texi
+++ b/doc/glibc-functions/strcasestr.texi
@@ -9,7 +9,12 @@ or @code{strcasestr}:
@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.
+
address@hidden
+This function can trigger memchr bugs on some platforms:
+glibc 2.10.
@end itemize
Portability problems fixed by Gnulib module @code{strcasestr}:
diff --git a/doc/posix-functions/strstr.texi b/doc/posix-functions/strstr.texi
index ffd2ad7..f92ba1b 100644
--- a/doc/posix-functions/strstr.texi
+++ b/doc/posix-functions/strstr.texi
@@ -4,14 +4,23 @@
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}:
address@hidden
address@hidden
+This function can trigger memchr bugs on some platforms:
+glibc 2.10.
address@hidden 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:
diff --git a/m4/memchr.m4 b/m4/memchr.m4
index 0f899d2..1194bac 100644
--- a/m4/memchr.m4
+++ b/m4/memchr.m4
@@ -1,10 +1,10 @@
-# 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
diff --git a/m4/strcasestr.m4 b/m4/strcasestr.m4
index e1e5390..d641958 100644
--- a/m4/strcasestr.m4
+++ b/m4/strcasestr.m4
@@ -1,20 +1,25 @@
-# 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
diff --git a/m4/strstr.m4 b/m4/strstr.m4
index f48bebb..c8beb9c 100644
--- a/m4/strstr.m4
+++ b/m4/strstr.m4
@@ -1,13 +1,24 @@
-# 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([[
diff --git a/modules/argz b/modules/argz
index 8217ff8..7ef73d5 100644
--- a/modules/argz
+++ b/modules/argz
@@ -12,6 +12,7 @@ mempcpy
stpcpy
strndup
strnlen
+strstr
configure.ac:
gl_FUNC_ARGZ
diff --git a/modules/gen-uni-tables b/modules/gen-uni-tables
index fd2735a..115853a 100644
--- a/modules/gen-uni-tables
+++ b/modules/gen-uni-tables
@@ -10,6 +10,7 @@ lib/unictype/3levelbit.h
Depends-on:
memcmp
strdup
+strstr-simple
configure.ac:
diff --git a/modules/mountlist b/modules/mountlist
index 526022c..65af9c1 100644
--- a/modules/mountlist
+++ b/modules/mountlist
@@ -11,6 +11,7 @@ m4/mountlist.m4
Depends-on:
stdbool
stdint
+strstr-simple
xalloc
configure.ac:
diff --git a/modules/strstr b/modules/strstr
index 251b2d7..dc33bd2 100644
--- a/modules/strstr
+++ b/modules/strstr
@@ -2,19 +2,12 @@ Description:
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:
diff --git a/modules/strstr-simple b/modules/strstr-simple
new file mode 100644
index 0000000..9ebf5da
--- /dev/null
+++ b/modules/strstr-simple
@@ -0,0 +1,28 @@
+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
--
1.6.3.rc3.2.g4b51
- Re: test-memchr crash, (continued)
- Re: test-memchr crash, Eric Blake, 2009/06/12
- Re: test-memchr crash, Simon Josefsson, 2009/06/13
- Re: test-memchr crash, Eric Blake, 2009/06/16
- Re: test-memchr crash, Simon Josefsson, 2009/06/16
- Re: test-memchr crash, Eric Blake, 2009/06/16
- strstr (was: test-memchr crash), Eric Blake, 2009/06/16
- Re: strstr (was: test-memchr crash), Bruno Haible, 2009/06/17
- Re: strstr, Eric Blake, 2009/06/17
- Re: strstr,
Eric Blake <=
- Re: strstr, Bruno Haible, 2009/06/18
- Re: strstr, Bruno Haible, 2009/06/18
- Re: strstr, Eric Blake, 2009/06/18
- Re: test-memchr crash, Simon Josefsson, 2009/06/16