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