[rubygems/rubygems] Use a constant empty tar header to avoid extra allocations
[ruby.git] / missing / strchr.c
blob465f07b61e43e5f3400ff73d43adf19ab17dea8a
1 /* public domain rewrite of strchr(3) and strrchr(3) */
3 #include "ruby/missing.h"
5 size_t strlen(const char*);
7 char *
8 strchr(const char *s, int c)
10 if (c == 0) return (char *)s + strlen(s);
11 while (*s) {
12 if (*s == c)
13 return (char *)s;
14 s++;
16 return 0;
19 char *
20 strrchr(const char *s, int c)
22 const char *save;
24 if (c == 0) return (char *)s + strlen(s);
25 save = 0;
26 while (*s) {
27 if (*s == c)
28 save = s;
29 s++;
31 return (char *)save;