xref: /csrg-svn/lib/libc/string/rindex.c (revision 34821)
11978Swnj /*
234618Sbostic  * Copyright (c) 1988 Regents of the University of California.
334618Sbostic  * All rights reserved.
434618Sbostic  *
534618Sbostic  * Redistribution and use in source and binary forms are permitted
6*34821Sbostic  * provided that the above copyright notice and this paragraph are
7*34821Sbostic  * duplicated in all such forms and that any documentation,
8*34821Sbostic  * advertising materials, and other materials related to such
9*34821Sbostic  * distribution and use acknowledge that the software was developed
10*34821Sbostic  * by the University of California, Berkeley.  The name of the
11*34821Sbostic  * University may not be used to endorse or promote products derived
12*34821Sbostic  * from this software without specific prior written permission.
13*34821Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*34821Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*34821Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1622103Smckusick  */
171978Swnj 
1834618Sbostic #if defined(LIBC_SCCS) && !defined(lint)
19*34821Sbostic static char sccsid[] = "@(#)rindex.c	5.4 (Berkeley) 06/27/88";
2034618Sbostic #endif /* LIBC_SCCS and not lint */
211978Swnj 
2234618Sbostic #include <stdio.h>
2334618Sbostic 
241978Swnj char *
2534618Sbostic rindex(p, ch)
2634618Sbostic 	register char *p, ch;
271978Swnj {
2834618Sbostic 	register char *save;
291978Swnj 
3034618Sbostic 	for (save = NULL;; ++p) {
3134618Sbostic 		if (*p == ch)
3234618Sbostic 			save = p;
3334618Sbostic 		if (!*p)
3434618Sbostic 			return(save);
3534618Sbostic 	}
3634618Sbostic 	/* NOTREACHED */
371978Swnj }
38