scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

strstr.c (267B)


      1 #include <stddef.h>
      2 #include <string.h>
      3 #undef strstr
      4 
      5 char *
      6 strstr(const char *s1, const char *s2)
      7 {
      8 	const char *p;
      9 	int c = *s2;
     10 
     11 	if (c == '\0')
     12 		return NULL;
     13 	for (p = s1; p = strchr(p, c); ++p) {
     14 		if (!strcmp(p, s2))
     15 			return (char *) p;
     16 	}
     17 	return NULL;
     18 }