Back to index

cell-binutils  2.17cvs20070401
strrchr.c
Go to the documentation of this file.
00001 /* Portable version of strrchr().
00002    This function is in the public domain. */
00003 
00004 /*
00005 
00006 @deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
00007 
00008 Returns a pointer to the last occurrence of the character @var{c} in
00009 the string @var{s}, or @code{NULL} if not found.  If @var{c} is itself the
00010 null character, the results are undefined.
00011 
00012 @end deftypefn
00013 
00014 */
00015 
00016 #include <ansidecl.h>
00017 
00018 char *
00019 strrchr (register const char *s, int c)
00020 {
00021   char *rtnval = 0;
00022 
00023   do {
00024     if (*s == c)
00025       rtnval = (char*) s;
00026   } while (*s++);
00027   return (rtnval);
00028 }