strstr: fix a bug whereby strstr would mistakenly return NULL
authorJim Meyering <meyering@redhat.com>
Thu, 24 Feb 2011 09:57:22 +0000 (10:57 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 24 Feb 2011 12:58:54 +0000 (13:58 +0100)
commit98d62d70dc39859781c830aaf1b81a97a576d99c
treeade1217c938ac9cf7d883085a233e4662bbd1808
parent29a425f1c5f2da5b37c172a38dbe2a4aaf2e9f6d
strstr: fix a bug whereby strstr would mistakenly return NULL

* lib/str-two-way.h (two_way_short_needle): Correct off-by-one error
in period calculation.
(two_way_long_needle): Likewise.
Reported by Ralf Wildenhues, with the short needle and haystack.
* tests/test-strstr.c: Add Ralf's test case to trigger the bug.
Add a more involved test to trigger the bug in two_way_long_needle.
ChangeLog
lib/str-two-way.h
tests/test-strstr.c