Ruby
2.0.0p645(2015-04-13revision50299)
Main Page
Modules
Data Structures
Files
File List
Globals
missing
strstr.c
Go to the documentation of this file.
1
/* public domain rewrite of strstr(3) */
2
3
#include "
ruby/missing.h
"
4
5
size_t
strlen
(
const
char
*);
6
7
char
*
8
strstr
(
const
char
*haystack,
const
char
*needle)
9
{
10
const
char
*hend;
11
const
char
*
a
, *
b
;
12
13
if
(*needle == 0)
return
(
char
*)haystack;
14
hend = haystack +
strlen
(haystack) -
strlen
(needle) + 1;
15
while
(haystack < hend) {
16
if
(*haystack == *needle) {
17
a = haystack;
18
b = needle;
19
for
(;;) {
20
if
(*b == 0)
return
(
char
*)haystack;
21
if
(*a++ != *b++) {
22
break
;
23
}
24
}
25
}
26
haystack++;
27
}
28
return
0;
29
}
strlen
size_t strlen(const char *)
a
Real * a
Definition:
bigdecimal.c:1196
missing.h
b
Real * b
Definition:
bigdecimal.c:1196
strstr
RUBY_EXTERN char * strstr(const char *, const char *)
Definition:
strstr.c:8
Generated on Thu Apr 30 2015 20:46:55 for Ruby by
1.8.5