1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/missing/strchr.c
matz 7b4486c877 * merged a patch from Takahiro Kambe <taca@back-street.net> to
support DragonFly BSD.  [ruby-dev:26984]

* object.c (rb_mod_cvar_get, rb_mod_cvar_set): document fix from
  sheepman <sheepman@sheepman.sakura.ne.jp>; a bug in visibility
  description.  [ruby-dev:26965]

* sprintf.c (rb_f_sprintf): warn "too many argument" on verbose
  mode (-v/-w); backported from 1.9.  [ruby-dev:26963]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-08 05:59:43 +00:00

32 lines
409 B
C

/* public domain rewrite of strchr(3) and strrchr(3) */
char *
strchr(s, c)
char *s;
int c;
{
if (c == 0) return s + strlen(s);
while (*s) {
if (*s == c)
return s;
s++;
}
return 0;
}
char *
strrchr(s, c)
char *s;
int c;
{
char *save;
if (c == 0) return s + strlen(s);
save = 0;
while (*s) {
if (*s == c)
save = s;
s++;
}
return save;
}