xref: /openbsd/gnu/lib/libiberty/src/strchr.c (revision 20fce977)
100bf4279Sespie /* Portable version of strchr()
200bf4279Sespie    This function is in the public domain.  */
300bf4279Sespie 
400bf4279Sespie /*
500bf4279Sespie 
69588ddcfSespie @deftypefn Supplemental char* strchr (const char *@var{s}, int @var{c})
700bf4279Sespie 
89588ddcfSespie Returns a pointer to the first occurrence of the character @var{c} in
99588ddcfSespie the string @var{s}, or @code{NULL} if not found.  If @var{c} is itself the
109588ddcfSespie null character, the results are undefined.
1100bf4279Sespie 
129588ddcfSespie @end deftypefn
139588ddcfSespie 
1400bf4279Sespie */
1500bf4279Sespie 
1600bf4279Sespie #include <ansidecl.h>
1700bf4279Sespie 
1800bf4279Sespie char *
strchr(register const char * s,int c)19*20fce977Smiod strchr (register const char *s, int c)
2000bf4279Sespie {
2100bf4279Sespie   do {
2200bf4279Sespie     if (*s == c)
2300bf4279Sespie       {
2400bf4279Sespie 	return (char*)s;
2500bf4279Sespie       }
2600bf4279Sespie   } while (*s++);
2700bf4279Sespie   return (0);
2800bf4279Sespie }
29