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