xref: /csrg-svn/lib/libc/string/strrchr.c (revision 34831)
124156Skre /*
234619Sbostic  * Copyright (c) 1988 Regents of the University of California.
334619Sbostic  * All rights reserved.
424156Skre  *
534619Sbostic  * Redistribution and use in source and binary forms are permitted
6*34831Sbostic  * provided that the above copyright notice and this paragraph are
7*34831Sbostic  * duplicated in all such forms and that any documentation,
8*34831Sbostic  * advertising materials, and other materials related to such
9*34831Sbostic  * distribution and use acknowledge that the software was developed
10*34831Sbostic  * by the University of California, Berkeley.  The name of the
11*34831Sbostic  * University may not be used to endorse or promote products derived
12*34831Sbostic  * from this software without specific prior written permission.
13*34831Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*34831Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*34831Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1624156Skre  */
1724156Skre 
1834619Sbostic #if defined(LIBC_SCCS) && !defined(lint)
19*34831Sbostic static char sccsid[] = "@(#)strrchr.c	5.4 (Berkeley) 06/27/88";
2034619Sbostic #endif /* LIBC_SCCS and not lint */
2124156Skre 
2234619Sbostic #ifdef notdef
2334619Sbostic static char sccsid[] = "@(#)rindex.c	5.3 (Berkeley) 6/2/88";
2434619Sbostic #endif
2534619Sbostic 
2634619Sbostic #include <stdio.h>
2734619Sbostic 
2824156Skre char *
2934619Sbostic strrchr(p, ch)
3034619Sbostic 	register char *p, ch;
3124156Skre {
3234619Sbostic 	register char *save;
3324156Skre 
3434619Sbostic 	for (save = NULL;; ++p) {
3534619Sbostic 		if (*p == ch)
3634619Sbostic 			save = p;
3734619Sbostic 		if (!*p)
3834619Sbostic 			return(save);
3934619Sbostic 	}
4034619Sbostic 	/* NOTREACHED */
4124156Skre }
42