xref: /netbsd-src/external/gpl3/binutils.old/dist/libiberty/strchr.c (revision 16dce51364ebe8aeafbae46bc5aa167b8115bc45)
1*16dce513Schristos /* Portable version of strchr()
2*16dce513Schristos    This function is in the public domain.  */
3*16dce513Schristos 
4*16dce513Schristos /*
5*16dce513Schristos 
6*16dce513Schristos @deftypefn Supplemental char* strchr (const char *@var{s}, int @var{c})
7*16dce513Schristos 
8*16dce513Schristos Returns a pointer to the first occurrence of the character @var{c} in
9*16dce513Schristos the string @var{s}, or @code{NULL} if not found.  If @var{c} is itself the
10*16dce513Schristos null character, the results are undefined.
11*16dce513Schristos 
12*16dce513Schristos @end deftypefn
13*16dce513Schristos 
14*16dce513Schristos */
15*16dce513Schristos 
16*16dce513Schristos #include <ansidecl.h>
17*16dce513Schristos 
18*16dce513Schristos char *
strchr(register const char * s,int c)19*16dce513Schristos strchr (register const char *s, int c)
20*16dce513Schristos {
21*16dce513Schristos   do {
22*16dce513Schristos     if (*s == c)
23*16dce513Schristos       {
24*16dce513Schristos 	return (char*)s;
25*16dce513Schristos       }
26*16dce513Schristos   } while (*s++);
27*16dce513Schristos   return (0);
28*16dce513Schristos }
29