xref: /haiku/src/system/libroot/posix/string/strstr.c (revision c90684742e7361651849be4116d0e5de3a817194)
1 /*
2  * Taken from Wikipedia, which declared it as "public domain".
3  */
4 
5 #include <sys/types.h>
6 #include <string.h>
7 
8 
9 char *
10 strstr(const char *s1, const char *s2)
11 {
12     size_t s2len;
13     /* Check for the null s2 case. */
14     if (*s2 == '\0')
15         return (char *) s1;
16     s2len = strlen(s2);
17     for (; (s1 = strchr(s1, *s2)) != NULL; s1++) {
18         if (strncmp(s1, s2, s2len) == 0)
19             return (char *)s1;
20     }
21     return NULL;
22 }
23 
24