Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 33 lines (27 sloc) 0.487 kB
a36e0c7 * parse.y (primary): rescue and ensure clauses should be allowed
matz authored
1 /* public domain rewrite of strchr(3) and strrchr(3) */
65a5162 1.4.0
matz authored
2
51b6bfb @nobu * missing/*.c: include missing.h
nobu authored
3 #include "ruby/missing.h"
4
e7413bc @nurse * missing/strchr.c: add strlen's prototype.
nurse authored
5 size_t strlen(const char*);
6
65a5162 1.4.0
matz authored
7 char *
64c8c73 * eval.c, file.c, ruby.c: removed strchr, strrchr, strstr definition
ocean authored
8 strchr(const char *s, int c)
65a5162 1.4.0
matz authored
9 {
64c8c73 * eval.c, file.c, ruby.c: removed strchr, strrchr, strstr definition
ocean authored
10 if (c == 0) return (char *)s + strlen(s);
a36e0c7 * parse.y (primary): rescue and ensure clauses should be allowed
matz authored
11 while (*s) {
12 if (*s == c)
64c8c73 * eval.c, file.c, ruby.c: removed strchr, strrchr, strstr definition
ocean authored
13 return (char *)s;
a36e0c7 * parse.y (primary): rescue and ensure clauses should be allowed
matz authored
14 s++;
15 }
16 return 0;
65a5162 1.4.0
matz authored
17 }
18
19 char *
64c8c73 * eval.c, file.c, ruby.c: removed strchr, strrchr, strstr definition
ocean authored
20 strrchr(const char *s, int c)
65a5162 1.4.0
matz authored
21 {
64c8c73 * eval.c, file.c, ruby.c: removed strchr, strrchr, strstr definition
ocean authored
22 const char *save;
65a5162 1.4.0
matz authored
23
64c8c73 * eval.c, file.c, ruby.c: removed strchr, strrchr, strstr definition
ocean authored
24 if (c == 0) return (char *)s + strlen(s);
b40d12a * missing/strchr.c (strrchr): fixed a bug in detecting NUL in a
matz authored
25 save = 0;
a36e0c7 * parse.y (primary): rescue and ensure clauses should be allowed
matz authored
26 while (*s) {
27 if (*s == c)
28 save = s;
29 s++;
30 }
64c8c73 * eval.c, file.c, ruby.c: removed strchr, strrchr, strstr definition
ocean authored
31 return (char *)save;
65a5162 1.4.0
matz authored
32 }
Something went wrong with that request. Please try again.