view modules/memmem @ 9538:43d9769bf4d0

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>
author Eric Blake <ebb9@byu.net>
date Wed, 19 Dec 2007 16:09:03 -0700
parents 5a0294ce5372
children f490fd6e4955
line wrap: on
line source

Description:
memmem() function: locate first substring in a buffer.

Files:
lib/memmem.c
m4/memmem.m4

Depends-on:
extensions
string
stdbool
malloca
memchr
memcmp

configure.ac:
gl_FUNC_MEMMEM
gl_STRING_MODULE_INDICATOR([memmem])

Makefile.am:

Include:
<string.h>

License:
LGPLv2+

Maintainer:
libc, Simon Josefsson