Fix return value.
Return a valid pointer (not NULL) when the character "c" is at the end of "src".
Change-Id: Iab0b677943f2c8a9fbb255c44689f5d6dc3535d7
Example:
memccpy(dest, "xzy", 'y', 3) should return dest+3 rather than null.
diff --git a/libc/string/memccpy.c b/libc/string/memccpy.c
index 2689e80..789fde6 100644
--- a/libc/string/memccpy.c
+++ b/libc/string/memccpy.c
@@ -38,18 +38,9 @@
for (;;) {
if (ch == c || p >= p_end) break;
*q++ = ch = *p++;
-
- if (ch == c || p >= p_end) break;
- *q++ = ch = *p++;
-
- if (ch == c || p >= p_end) break;
- *q++ = ch = *p++;
-
- if (ch == c || p >= p_end) break;
- *q++ = ch = *p++;
}
- if (p >= p_end)
+ if (p >= p_end && ch != c)
return NULL;
return q;