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