blob: 92cf24c6778d7d4934598be426cb60b75f6dda96 [file] [log] [blame]
Jens Axboe9ad8da82013-04-05 14:44:03 +02001#include <ctype.h>
2#include <stddef.h>
3
4char *strcasestr(const char *s1, const char *s2)
5{
6 const char *s = s1;
7 const char *p = s2;
8
9 do {
10 if (!*p)
11 return (char *) s1;
12 if ((*p == *s) ||
13 (tolower(*p) == tolower(*s))) {
14 ++p;
15 ++s;
16 } else {
17 p = s2;
18 if (!*s)
19 return NULL;
20 s = ++s1;
21 }
22 } while (1);
23
24 return *p ? NULL : (char *) s1;
25}