add rdoc.
[ruby-svn.git] / missing / strchr.c
blobbebd7ba5782dd6e6e948ac498715820fb7459b9e
1 /* public domain rewrite of strchr(3) and strrchr(3) */
3 char *
4 strchr(const char *s, int c)
6 if (c == 0) return (char *)s + strlen(s);
7 while (*s) {
8 if (*s == c)
9 return (char *)s;
10 s++;
12 return 0;
15 char *
16 strrchr(const char *s, int c)
18 const char *save;
20 if (c == 0) return (char *)s + strlen(s);
21 save = 0;
22 while (*s) {
23 if (*s == c)
24 save = s;
25 s++;
27 return (char *)save;