blob: b9d8a35ed793f7890503d5532e66f9a060a9294b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <lib9.h>
/*
* Return pointer to first occurrence of s2 in s1,
* 0 if none
*/
char*
strstr(char *s1, char *s2)
{
char *p;
int f, n;
f = s2[0];
if(f == 0)
return s1;
n = strlen(s2);
for(p=strchr(s1, f); p; p=strchr(p+1, f))
if(strncmp(p, s2, n) == 0)
return p;
return 0;
}
|