156067Smarkm/* Portable version of strrchr().
256067Smarkm   This function is in the public domain. */
3117728Smarkm
4125261Sru/*
5201919Santoine
6125491Sru@deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
7178828Sdfr
8117728SmarkmReturns a pointer to the last occurrence of the character @var{c} in
9117728Smarkmthe string @var{s}, or @code{NULL} if not found.  If @var{c} is itself the
1056067Smarkmnull character, the results are undefined.
1156067Smarkm
12125491Sru@end deftypefn
13
14*/
15
16#include <ansidecl.h>
17
18char *
19strrchr (register const char *s, int c)
20{
21  char *rtnval = 0;
22
23  do {
24    if (*s == c)
25      rtnval = (char*) s;
26  } while (*s++);
27  return (rtnval);
28}
29