Commit | Line | Data |
---|---|---|
5d413e08 SW |
1 | #ifndef CONFIG_STRCASESTR |
2 | ||
9ad8da82 JA |
3 | #include <ctype.h> |
4 | #include <stddef.h> | |
5d413e08 | 5 | #include "strcasestr.h" |
2c2c93d8 | 6 | |
9ad8da82 JA |
7 | char *strcasestr(const char *s1, const char *s2) |
8 | { | |
9 | const char *s = s1; | |
10 | const char *p = s2; | |
11 | ||
12 | do { | |
13 | if (!*p) | |
14 | return (char *) s1; | |
15 | if ((*p == *s) || | |
16 | (tolower(*p) == tolower(*s))) { | |
17 | ++p; | |
18 | ++s; | |
19 | } else { | |
20 | p = s2; | |
21 | if (!*s) | |
22 | return NULL; | |
23 | s = ++s1; | |
24 | } | |
25 | } while (1); | |
26 | ||
27 | return *p ? NULL : (char *) s1; | |
28 | } | |
2c2c93d8 JA |
29 | |
30 | #endif |