xref: /openbsd-src/gnu/lib/libiberty/src/strrchr.c (revision 20fce977aadac3358da45d5027d7d19cdc03b0fe)
100bf4279Sespie /* Portable version of strrchr().
200bf4279Sespie    This function is in the public domain. */
300bf4279Sespie 
400bf4279Sespie /*
500bf4279Sespie 
69588ddcfSespie @deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
700bf4279Sespie 
89588ddcfSespie Returns a pointer to the last 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 *
strrchr(register const char * s,int c)19*20fce977Smiod strrchr (register const char *s, int c)
2000bf4279Sespie {
2100bf4279Sespie   char *rtnval = 0;
2200bf4279Sespie 
2300bf4279Sespie   do {
2400bf4279Sespie     if (*s == c)
2500bf4279Sespie       rtnval = (char*) s;
2600bf4279Sespie   } while (*s++);
2700bf4279Sespie   return (rtnval);
2800bf4279Sespie }
29