Home | History | Annotate | Download | only in lib
      1 #include <ctype.h>
      2 #include <stddef.h>
      3 
      4 char *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 }
     26