1 /* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)rindex.c 5.9 (Berkeley) 02/24/91"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 #include <stddef.h> 13 #include <string.h> 14 15 char * 16 #ifdef STRRCHR 17 strrchr(p, ch) 18 #else 19 rindex(p, ch) 20 #endif 21 register const char *p, ch; 22 { 23 register char *save; 24 25 for (save = NULL;; ++p) { 26 if (*p == ch) 27 save = (char *)p; 28 if (!*p) 29 return(save); 30 } 31 /* NOTREACHED */ 32 } 33