Rewrite memmem to guarantee linear complexity without malloc.
authorEric Blake <ebb9@byu.net>
Sat, 5 Jan 2008 21:09:11 +0000 (14:09 -0700)
committerEric Blake <ebb9@byu.net>
Tue, 8 Jan 2008 13:24:40 +0000 (06:24 -0700)
commit9d8d6cd7a56291988ca24977416d64dda885ed49
tree55bba3405f8cfcfdd76b22572a893b6783e1280b
parent9ca9a0b2e128e4429088396cdcd0ddb5f68c8649
Rewrite memmem to guarantee linear complexity without malloc.

* lib/memmem.c (memmem): Use Two-Way rather than
Knuth-Morris-Pratt, to allow O(1) space usage.
(critical_factorization, two_way_short_needle)
(two_way_long_needle): New functions.
(knuth_morris_pratt): Delete.
* modules/memmem (Depends-on): No longer need malloca or stdbool.
Add stdint.
* tests/test-memmem.c (main): Add tests for periodic needle and
sublinear performance.
* doc/functions/memmem.texi (memmem): Document other deficiencies
in cygwin and older glibc.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/functions/memmem.texi
lib/memmem.c
modules/memmem
tests/test-memmem.c