This function originated in glibc, and this matches the behaviour of their implementation.
An empty big string (arg "l") is handled by the existing l_len < s_len test.
Paths
| Differential D2657 Authored by emaste on May 26 2015, 6:19 PM.
Details
Summary This function originated in glibc, and this matches the behaviour of their implementation. An empty big string (arg "l") is handled by the existing l_len < s_len test. Test Plan kyua test lib/libc/string/memmem:memmem_basic
Diff Detail
Event Timelineemaste updated this object. ngie edited edge metadata. Comment ActionsLGTM: $ cat /etc/redhat-release Fedora release 20 (Heisenbug) $ ./test_memmem ; echo $? 0 $ cat test_memmem.c #define _GNU_SOURCE #include <assert.h> #include <string.h> char p0[] = ""; int lp0 = 0; char b0[] = ""; int lb0 = 0; char b2[] = "0123456789"; int lb2 = 10; int main(void) { assert(memmem(b2, lb2, p0, lp0) == b2); assert(memmem(b0, lb0, p0, lp0) == b0); return 0; } This revision is now accepted and ready to land.May 26 2015, 6:43 PM2015-05-26 18:43:35 (UTC+0) Comment Actions For reference, NetBSD, OpenBSD and musl share the "new" behaviour (with this change) with glibc This revision now requires review to proceed.May 26 2015, 6:55 PM2015-05-26 18:55:30 (UTC+0) emaste added a child revision: D2601: libc: Use musl's O(n) memmem and strstr.May 26 2015, 8:04 PM2015-05-26 20:04:19 (UTC+0) bapt edited edge metadata. This revision is now accepted and ready to land.May 26 2015, 8:06 PM2015-05-26 20:06:43 (UTC+0) Closed by commit rS283584: memmem(3): empty little string matches the beginning of the big string (authored by emaste). · Explain WhyMay 26 2015, 9:16 PM2015-05-26 21:16:09 (UTC+0) This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 5714 contrib/netbsd-tests/lib/libc/string/t_memmem.c
lib/libc/string/memmem.3
lib/libc/string/memmem.c
|