1668afe26SAntonio Nino Diaz /*- 2668afe26SAntonio Nino Diaz * SPDX-License-Identifier: BSD-3-Clause 3668afe26SAntonio Nino Diaz * 4668afe26SAntonio Nino Diaz * Copyright (c) 1988, 1993 5668afe26SAntonio Nino Diaz * The Regents of the University of California. All rights reserved. 6668afe26SAntonio Nino Diaz * 7668afe26SAntonio Nino Diaz * Redistribution and use in source and binary forms, with or without 8668afe26SAntonio Nino Diaz * modification, are permitted provided that the following conditions 9668afe26SAntonio Nino Diaz * are met: 10668afe26SAntonio Nino Diaz * 1. Redistributions of source code must retain the above copyright 11668afe26SAntonio Nino Diaz * notice, this list of conditions and the following disclaimer. 12668afe26SAntonio Nino Diaz * 2. Redistributions in binary form must reproduce the above copyright 13668afe26SAntonio Nino Diaz * notice, this list of conditions and the following disclaimer in the 14668afe26SAntonio Nino Diaz * documentation and/or other materials provided with the distribution. 15668afe26SAntonio Nino Diaz * 3. Neither the name of the University nor the names of its contributors 16668afe26SAntonio Nino Diaz * may be used to endorse or promote products derived from this software 17668afe26SAntonio Nino Diaz * without specific prior written permission. 18668afe26SAntonio Nino Diaz * 19668afe26SAntonio Nino Diaz * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20668afe26SAntonio Nino Diaz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21668afe26SAntonio Nino Diaz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22668afe26SAntonio Nino Diaz * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23668afe26SAntonio Nino Diaz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24668afe26SAntonio Nino Diaz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25668afe26SAntonio Nino Diaz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26668afe26SAntonio Nino Diaz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27668afe26SAntonio Nino Diaz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28668afe26SAntonio Nino Diaz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29668afe26SAntonio Nino Diaz * SUCH DAMAGE. 30668afe26SAntonio Nino Diaz */ 31668afe26SAntonio Nino Diaz 32668afe26SAntonio Nino Diaz #include <stddef.h> 33*34d7f196SBoyan Karatotev #include <string_private.h> 34668afe26SAntonio Nino Diaz 35668afe26SAntonio Nino Diaz char * 36668afe26SAntonio Nino Diaz strrchr(const char *p, int ch) 37668afe26SAntonio Nino Diaz { 38668afe26SAntonio Nino Diaz char *save; 39668afe26SAntonio Nino Diaz char c; 40668afe26SAntonio Nino Diaz 41668afe26SAntonio Nino Diaz c = ch; 42668afe26SAntonio Nino Diaz for (save = NULL;; ++p) { 43668afe26SAntonio Nino Diaz if (*p == c) 44668afe26SAntonio Nino Diaz save = (char *)p; 45668afe26SAntonio Nino Diaz if (*p == '\0') 46668afe26SAntonio Nino Diaz return (save); 47668afe26SAntonio Nino Diaz } 48668afe26SAntonio Nino Diaz /* NOTREACHED */ 49668afe26SAntonio Nino Diaz } 50