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