[Midnightbsd-cvs] src [10524] trunk/lib/libc/string/memmem.c: tweak

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Thu Jun 7 18:35:18 EDT 2018


Revision: 10524
          http://svnweb.midnightbsd.org/src/?rev=10524
Author:   laffer1
Date:     2018-06-07 18:35:17 -0400 (Thu, 07 Jun 2018)
Log Message:
-----------
tweak

Modified Paths:
--------------
    trunk/lib/libc/string/memmem.c

Modified: trunk/lib/libc/string/memmem.c
===================================================================
--- trunk/lib/libc/string/memmem.c	2018-06-07 22:33:46 UTC (rev 10523)
+++ trunk/lib/libc/string/memmem.c	2018-06-07 22:35:17 UTC (rev 10524)
@@ -42,9 +42,9 @@
 	const char *cl = (const char *)l;
 	const char *cs = (const char *)s;
 
-	/* we need something to compare */
-	if (l_len == 0 || s_len == 0)
-		return NULL;
+	/* empty "s" matches the beginning of "l" */
+	if (s_len == 0)
+		return (void *)cl;
 
 	/* "s" must be smaller or equal to "l" */
 	if (l_len < s_len)



More information about the Midnightbsd-cvs mailing list