xref: /csrg-svn/lib/libc/string/rindex.c (revision 34618)
11978Swnj /*
2*34618Sbostic  * Copyright (c) 1988 Regents of the University of California.
3*34618Sbostic  * All rights reserved.
4*34618Sbostic  *
5*34618Sbostic  * Redistribution and use in source and binary forms are permitted
6*34618Sbostic  * provided that this notice is preserved and that due credit is given
7*34618Sbostic  * to the University of California at Berkeley. The name of the University
8*34618Sbostic  * may not be used to endorse or promote products derived from this
9*34618Sbostic  * software without specific written prior permission. This software
10*34618Sbostic  * is provided ``as is'' without express or implied warranty.
1122103Smckusick  */
121978Swnj 
13*34618Sbostic #if defined(LIBC_SCCS) && !defined(lint)
14*34618Sbostic static char sccsid[] = "@(#)rindex.c	5.3 (Berkeley) 06/02/88";
15*34618Sbostic #endif /* LIBC_SCCS and not lint */
161978Swnj 
17*34618Sbostic #include <stdio.h>
18*34618Sbostic 
191978Swnj char *
20*34618Sbostic rindex(p, ch)
21*34618Sbostic 	register char *p, ch;
221978Swnj {
23*34618Sbostic 	register char *save;
241978Swnj 
25*34618Sbostic 	for (save = NULL;; ++p) {
26*34618Sbostic 		if (*p == ch)
27*34618Sbostic 			save = p;
28*34618Sbostic 		if (!*p)
29*34618Sbostic 			return(save);
30*34618Sbostic 	}
31*34618Sbostic 	/* NOTREACHED */
321978Swnj }
33