repo.or.cz
/
haiku.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
vfs: check userland buffers before reading them.
[haiku.git]
/
src
/
system
/
libroot
/
posix
/
string
/
strstr.c
blob
3f8c9e532f1292dffee411a94b06da65dc3a9261
1
/*
2
* Taken from Wikipedia, which declared it as "public domain".
3
*/
4
5
#include <sys/types.h>
6
#include <string.h>
7
8
9
char
*
10
strstr
(
const char
*
s1
,
const char
*
s2
)
11
{
12
size_t
s2len
;
13
/* Check for the null s2 case. */
14
if
(*
s2
==
'\0'
)
15
return
(
char
*)
s1
;
16
s2len
=
strlen
(
s2
);
17
for
(; (
s1
=
strchr
(
s1
, *
s2
)) !=
NULL
;
s1
++) {
18
if
(
strncmp
(
s1
,
s2
,
s2len
) ==
0
)
19
return
(
char
*)
s1
;
20
}
21
return
NULL
;
22
}
23