blob: 2db47f4adf012c7629bb98f3652f8b5dad6a1ac4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#include "rocklibc.h"
char *strstr(const char *haystack, const char *needle) {
size_t nl=strlen(needle);
size_t hl=strlen(haystack);
int i;
if (!nl) goto found;
if (nl>hl) return 0;
for (i=hl-nl+1; __likely(i); --i) {
if (*haystack==*needle && !memcmp(haystack,needle,nl))
found:
return (char*)haystack;
++haystack;
}
return 0;
}
|