strrchr.c revision 169696
1240116Smarcel/* Portable version of strrchr().
2240116Smarcel   This function is in the public domain. */
3240116Smarcel
4240116Smarcel/*
5240116Smarcel
6240116Smarcel@deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
7240116Smarcel
8240116SmarcelReturns a pointer to the last occurrence of the character @var{c} in
9240116Smarcelthe string @var{s}, or @code{NULL} if not found.  If @var{c} is itself the
10240116Smarcelnull character, the results are undefined.
11240116Smarcel
12240116Smarcel@end deftypefn
13240116Smarcel
14240116Smarcel*/
15240116Smarcel
16240116Smarcel#include <ansidecl.h>
17240116Smarcel
18240116Smarcelchar *
19240116Smarcelstrrchr (register const char *s, int c)
20240116Smarcel{
21240116Smarcel  char *rtnval = 0;
22240116Smarcel
23240116Smarcel  do {
24240116Smarcel    if (*s == c)
25240116Smarcel      rtnval = (char*) s;
26275988Sngie  } while (*s++);
27275988Sngie  return (rtnval);
28240116Smarcel}
29240116Smarcel