home *** CD-ROM | disk | FTP | other *** search
- /* from Henry Spencer's stringlib */
- #include <string.h>
-
- /*
- * strrchr - find last occurrence of a character in a string
- */
- #ifdef __GNUC__
- asm(".text; .even; .globl _rindex; _rindex:"); /* dept of dirty tricks */
- #else
- char *
- rindex(s, charwanted)
- const char *s;
- char charwanted;
- {
- return strrchr(s, charwanted);
- }
- #endif
-
- char * /* found char, or NULL if none */
- strrchr(s, charwanted)
- const char *s;
- register char charwanted;
- {
- register char c;
- register const char *place;
-
- place = NULL;
- while (c = *s++)
- if (c == charwanted)
- place = s - 1;
- if (charwanted == '\0')
- return((char *)--s);
- return (char *)place;
- }
-