diff options
author | Eric Blake <ebb9@byu.net> | 2007-12-19 16:09:03 -0700 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2007-12-20 06:02:01 -0700 |
commit | fc068cf4eb6814e848e4dc54e1c5cf4c30a79a6f (patch) | |
tree | a195a67b5ddd7d22b8c62277871cab7435cc7b54 /lib/string.in.h | |
parent | e323f261972032e4a1eeee6102c2327e97c808df (diff) | |
download | gnulib-fc068cf4eb6814e848e4dc54e1c5cf4c30a79a6f.tar.gz |
Fix memmem to avoid O(n^2) worst-case complexity.
* lib/memmem.c (knuth_morris_pratt): New function.
(memmem): Use it if first few naive iterations fail.
* m4/memmem.m4 (gl_FUNC_MEMMEM): Detect cygwin bug.
* modules/memcmp (License): Set to LGPLv2+, not LGPL.
* modules/memchr (License): Likewise.
* modules/memmem (Depends-on): Add memcmp, memchr, stdbool, and
malloca.
* tests/test-memmem.c: Rewrite, borrowing ideas from
test-mbsstr1.c; the old version wouldn't even compile!
* modules/memmem-tests: New file.
* lib/string.in.h (rpl_memmem): Add declaration.
* modules/string (Makefile.am): Substitute REPLACE_MEMMEM.
* m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Default for
REPLACE_MEMMEM.
Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'lib/string.in.h')
-rw-r--r-- | lib/string.in.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/string.in.h b/lib/string.in.h index c60e2f3160..09205e7f0c 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -35,7 +35,10 @@ extern "C" { /* Return the first occurrence of NEEDLE in HAYSTACK. */ #if @GNULIB_MEMMEM@ -# if ! @HAVE_DECL_MEMMEM@ +# if @REPLACE_MEMMEM@ +# define memmem rpl_memmem +# endif +# if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@ extern void *memmem (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len); # endif |