Ruby
2.1.10p492(2016-04-01revision54464)
Main Page
Modules
Data Structures
Files
File List
Globals
missing
strchr.c
Go to the documentation of this file.
1
/* public domain rewrite of strchr(3) and strrchr(3) */
2
3
#include "
ruby/missing.h
"
4
5
size_t
strlen
(
const
char
*);
6
7
char
*
8
strchr
(
const
char
*
s
,
int
c
)
9
{
10
if
(c == 0)
return
(
char
*)s +
strlen
(s);
11
while
(*s) {
12
if
(*s == c)
13
return
(
char
*)
s
;
14
s++;
15
}
16
return
0;
17
}
18
19
char
*
20
strrchr
(
const
char
*
s
,
int
c
)
21
{
22
const
char
*save;
23
24
if
(c == 0)
return
(
char
*)s +
strlen
(s);
25
save = 0;
26
while
(*s) {
27
if
(*s == c)
28
save =
s
;
29
s++;
30
}
31
return
(
char
*)save;
32
}
strlen
size_t strlen(const char *)
missing.h
s
register char * s
Definition:
os2.c:56
strchr
char * strchr(char *, char)
c
VpDivd * c
Definition:
bigdecimal.c:1223
strrchr
char * strrchr(const char *, const char)
Generated by
1.8.5