diff options
Diffstat (limited to 'mdk-stage1/minilibc.c')
-rw-r--r-- | mdk-stage1/minilibc.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mdk-stage1/minilibc.c b/mdk-stage1/minilibc.c index c98d87e24..ac0ffe334 100644 --- a/mdk-stage1/minilibc.c +++ b/mdk-stage1/minilibc.c @@ -188,6 +188,21 @@ char * strchr(char * str, int ch) return NULL; } + +char * strstr(char *haystack, char *needle) +{ + char * tmp = haystack; + while ((tmp = strchr(tmp, needle[0])) != NULL) { + int i = 1; + while (i < strlen(tmp) && i < strlen(needle) && tmp[i] == needle[i]) + i++; + if (needle[i] == '\0') + return tmp; + tmp++; + } + return NULL; +} + void print_int(int fd, int i) { char buf[10]; |