source:
trunk/sys/dietlibc/strstr.c
@
131
Last change on this file since 131 was 1, checked in by , 8 years ago | |
---|---|
File size: 352 bytes |
Rev | Line | |
---|---|---|
[1] | 1 | #include <string.h> |
2 | ||
3 | char *strstr(const char *haystack, const char *needle) { | |
4 | size_t nl=strlen(needle); | |
5 | size_t hl=strlen(haystack); | |
6 | size_t i; | |
7 | if (!nl) goto found; | |
8 | if (nl>hl) return 0; | |
9 | for (i=hl-nl+1; i; --i) { | |
10 | if (*haystack==*needle && !memcmp(haystack,needle,nl)) | |
11 | found: | |
12 | return (char*)haystack; | |
13 | ++haystack; | |
14 | } | |
15 | return 0; | |
16 | } |
Note: See TracBrowser
for help on using the repository browser.