strstr.c - scc - simple c99 compiler
(HTM) git clone git://git.simple-cc.org/scc
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
strstr.c (307B)
---
1 #include <stddef.h>
2 #include <string.h>
3
4 #undef strstr
5
6 char *
7 strstr(const char *s1, const char *s2)
8 {
9 const char *p;
10 int c = *s2;
11 int len;
12
13 if ((len = strlen(s2)) == 0)
14 return (char *) s1;
15
16 for (p = s1; p = strchr(p, c); ++p) {
17 if (!strncmp(p, s2, len))
18 return (char *) p;
19 }
20
21 return NULL;
22 }