home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib25.zoo / strrchr.c < prev    next >
C/C++ Source or Header  |  1992-09-17  |  683b  |  35 lines

  1. /* from Henry Spencer's stringlib */
  2. #include <string.h>
  3.  
  4. /*
  5.  * strrchr - find last occurrence of a character in a string
  6.  */
  7. #ifdef __GNUC__
  8. asm(".stabs \"_rindex\",5,0,0,_strrchr"); /* dept of clean tricks */
  9. #else
  10. char *
  11. rindex(s, charwanted)
  12.       const char *s;
  13.       int charwanted;
  14. {
  15.       return strrchr(s, charwanted);
  16. }
  17. #endif
  18.  
  19. char *                /* found char, or NULL if none */
  20. strrchr(s, charwanted)
  21. const char *s;
  22. register int charwanted;
  23. {
  24.     register char c;
  25.     register const char *place;
  26.  
  27.     place = NULL;
  28.     while ((c = *s++) != 0)
  29.         if (c == charwanted)
  30.             place = s - 1;
  31.     if (charwanted == '\0')
  32.         return((char *)--s);
  33.     return (char *)place;
  34. }
  35.