xref: /csrg-svn/lib/libc/string/rindex.c (revision 42635)
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.7 (Berkeley) 06/01/90";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <stddef.h>
13 #include <string.h>
14 
15 char *
16 rindex(p, ch)
17 	register char *p, ch;
18 {
19 	register char *save;
20 
21 	for (save = NULL;; ++p) {
22 		if (*p == ch)
23 			save = p;
24 		if (!*p)
25 			return(save);
26 	}
27 	/* NOTREACHED */
28 }
29