libc: add reference to two-way algorithm and bad shift table in memmem/strstr

Requested by:	ed
This commit is contained in:
Ed Maste 2017-03-18 00:53:24 +00:00
parent 88521634e9
commit 01dc206b22
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=315468
2 changed files with 16 additions and 0 deletions

View File

@ -58,6 +58,14 @@ static char *fourbyte_memmem(const unsigned char *h, size_t k, const unsigned ch
#define BITOP(a,b,op) \
((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a))))
/*
* Two Way string search algorithm, with a bad shift table applied to the last
* byte of the window. A bit array marks which entries in the shift table are
* initialized to avoid fully initializing a 1kb/2kb table.
*
* Reference: CROCHEMORE M., PERRIN D., 1991, Two-way string-matching,
* Journal of the ACM 38(3):651-675
*/
static char *twoway_memmem(const unsigned char *h, const unsigned char *z, const unsigned char *n, size_t l)
{
size_t i, ip, jp, k, p, ms, p0, mem, mem0;

View File

@ -55,6 +55,14 @@ static char *fourbyte_strstr(const unsigned char *h, const unsigned char *n)
#define BITOP(a,b,op) \
((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a))))
/*
* Two Way string search algorithm, with a bad shift table applied to the last
* byte of the window. A bit array marks which entries in the shift table are
* initialized to avoid fully initializing a 1kb/2kb table.
*
* Reference: CROCHEMORE M., PERRIN D., 1991, Two-way string-matching,
* Journal of the ACM 38(3):651-675
*/
static char *twoway_strstr(const unsigned char *h, const unsigned char *n)
{
const unsigned char *z;