xref: /csrg-svn/lib/libc/string/strrchr.c (revision 34619)
124156Skre /*
2*34619Sbostic  * Copyright (c) 1988 Regents of the University of California.
3*34619Sbostic  * All rights reserved.
424156Skre  *
5*34619Sbostic  * Redistribution and use in source and binary forms are permitted
6*34619Sbostic  * provided that this notice is preserved and that due credit is given
7*34619Sbostic  * to the University of California at Berkeley. The name of the University
8*34619Sbostic  * may not be used to endorse or promote products derived from this
9*34619Sbostic  * software without specific written prior permission. This software
10*34619Sbostic  * is provided ``as is'' without express or implied warranty.
1124156Skre  */
1224156Skre 
13*34619Sbostic #if defined(LIBC_SCCS) && !defined(lint)
14*34619Sbostic static char sccsid[] = "@(#)strrchr.c	5.3 (Berkeley) 06/02/88";
15*34619Sbostic #endif /* LIBC_SCCS and not lint */
1624156Skre 
17*34619Sbostic #ifdef notdef
18*34619Sbostic static char sccsid[] = "@(#)rindex.c	5.3 (Berkeley) 6/2/88";
19*34619Sbostic #endif
20*34619Sbostic 
21*34619Sbostic #include <stdio.h>
22*34619Sbostic 
2324156Skre char *
24*34619Sbostic strrchr(p, ch)
25*34619Sbostic 	register char *p, ch;
2624156Skre {
27*34619Sbostic 	register char *save;
2824156Skre 
29*34619Sbostic 	for (save = NULL;; ++p) {
30*34619Sbostic 		if (*p == ch)
31*34619Sbostic 			save = p;
32*34619Sbostic 		if (!*p)
33*34619Sbostic 			return(save);
34*34619Sbostic 	}
35*34619Sbostic 	/* NOTREACHED */
3624156Skre }
37