Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_tlsv12/sys/src/libc/port/strstr.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
 
4
/*
5
 * Return pointer to first occurrence of s2 in s1,
6
 * 0 if none
7
 */
8
char*
9
strstr(char *s1, char *s2)
10
{
11
	char *p, *pa, *pb;
12
	int c0, c;
13
 
14
	c0 = *s2;
15
	if(c0 == 0)
16
		return s1;
17
	s2++;
18
	for(p=strchr(s1, c0); p; p=strchr(p+1, c0)) {
19
		pa = p;
20
		for(pb=s2;; pb++) {
21
			c = *pb;
22
			if(c == 0)
23
				return p;
24
			if(c != *++pa)
25
				break;
26
		}
27
	}
28
	return 0;
29
}