xref: /csrg-svn/lib/libc/string/rindex.c (revision 42181)
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
634821Sbostic  * provided that the above copyright notice and this paragraph are
734821Sbostic  * duplicated in all such forms and that any documentation,
834821Sbostic  * advertising materials, and other materials related to such
934821Sbostic  * distribution and use acknowledge that the software was developed
1034821Sbostic  * by the University of California, Berkeley.  The name of the
1134821Sbostic  * University may not be used to endorse or promote products derived
1234821Sbostic  * from this software without specific prior written permission.
1334821Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1434821Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1534821Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1622103Smckusick  */
171978Swnj 
1834618Sbostic #if defined(LIBC_SCCS) && !defined(lint)
19*42181Sbostic static char sccsid[] = "@(#)rindex.c	5.6 (Berkeley) 05/17/90";
2034618Sbostic #endif /* LIBC_SCCS and not lint */
211978Swnj 
2242148Sbostic #include <stddef.h>
23*42181Sbostic #include <string.h>
2434618Sbostic 
251978Swnj char *
2634618Sbostic rindex(p, ch)
2734618Sbostic 	register char *p, ch;
281978Swnj {
2934618Sbostic 	register char *save;
301978Swnj 
3134618Sbostic 	for (save = NULL;; ++p) {
3234618Sbostic 		if (*p == ch)
3334618Sbostic 			save = p;
3434618Sbostic 		if (!*p)
3534618Sbostic 			return(save);
3634618Sbostic 	}
3734618Sbostic 	/* NOTREACHED */
381978Swnj }
39