1*668afe26SAntonio Nino Diaz /*- 2*668afe26SAntonio Nino Diaz * SPDX-License-Identifier: BSD-3-Clause 3*668afe26SAntonio Nino Diaz * 4*668afe26SAntonio Nino Diaz * Copyright (c) 1988, 1993 5*668afe26SAntonio Nino Diaz * The Regents of the University of California. All rights reserved. 6*668afe26SAntonio Nino Diaz * 7*668afe26SAntonio Nino Diaz * Redistribution and use in source and binary forms, with or without 8*668afe26SAntonio Nino Diaz * modification, are permitted provided that the following conditions 9*668afe26SAntonio Nino Diaz * are met: 10*668afe26SAntonio Nino Diaz * 1. Redistributions of source code must retain the above copyright 11*668afe26SAntonio Nino Diaz * notice, this list of conditions and the following disclaimer. 12*668afe26SAntonio Nino Diaz * 2. Redistributions in binary form must reproduce the above copyright 13*668afe26SAntonio Nino Diaz * notice, this list of conditions and the following disclaimer in the 14*668afe26SAntonio Nino Diaz * documentation and/or other materials provided with the distribution. 15*668afe26SAntonio Nino Diaz * 3. Neither the name of the University nor the names of its contributors 16*668afe26SAntonio Nino Diaz * may be used to endorse or promote products derived from this software 17*668afe26SAntonio Nino Diaz * without specific prior written permission. 18*668afe26SAntonio Nino Diaz * 19*668afe26SAntonio Nino Diaz * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20*668afe26SAntonio Nino Diaz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21*668afe26SAntonio Nino Diaz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22*668afe26SAntonio Nino Diaz * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23*668afe26SAntonio Nino Diaz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24*668afe26SAntonio Nino Diaz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25*668afe26SAntonio Nino Diaz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26*668afe26SAntonio Nino Diaz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27*668afe26SAntonio Nino Diaz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28*668afe26SAntonio Nino Diaz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29*668afe26SAntonio Nino Diaz * SUCH DAMAGE. 30*668afe26SAntonio Nino Diaz */ 31*668afe26SAntonio Nino Diaz 32*668afe26SAntonio Nino Diaz #if defined(LIBC_SCCS) && !defined(lint) 33*668afe26SAntonio Nino Diaz static char sccsid[] = "@(#)rindex.c 8.1 (Berkeley) 6/4/93"; 34*668afe26SAntonio Nino Diaz #endif /* LIBC_SCCS and not lint */ 35*668afe26SAntonio Nino Diaz #include <sys/cdefs.h> 36*668afe26SAntonio Nino Diaz __FBSDID("$FreeBSD$"); 37*668afe26SAntonio Nino Diaz 38*668afe26SAntonio Nino Diaz #include <stddef.h> 39*668afe26SAntonio Nino Diaz #include <string.h> 40*668afe26SAntonio Nino Diaz 41*668afe26SAntonio Nino Diaz char * 42*668afe26SAntonio Nino Diaz strrchr(const char *p, int ch) 43*668afe26SAntonio Nino Diaz { 44*668afe26SAntonio Nino Diaz char *save; 45*668afe26SAntonio Nino Diaz char c; 46*668afe26SAntonio Nino Diaz 47*668afe26SAntonio Nino Diaz c = ch; 48*668afe26SAntonio Nino Diaz for (save = NULL;; ++p) { 49*668afe26SAntonio Nino Diaz if (*p == c) 50*668afe26SAntonio Nino Diaz save = (char *)p; 51*668afe26SAntonio Nino Diaz if (*p == '\0') 52*668afe26SAntonio Nino Diaz return (save); 53*668afe26SAntonio Nino Diaz } 54*668afe26SAntonio Nino Diaz /* NOTREACHED */ 55*668afe26SAntonio Nino Diaz } 56*668afe26SAntonio Nino Diaz 57*668afe26SAntonio Nino Diaz __weak_reference(strrchr, rindex); 58