122fec34aSEd Schouten /*- 222fec34aSEd Schouten * Copyright (c) 1990, 1993 322fec34aSEd Schouten * The Regents of the University of California. All rights reserved. 422fec34aSEd Schouten * 522fec34aSEd Schouten * Redistribution and use in source and binary forms, with or without 622fec34aSEd Schouten * modification, are permitted provided that the following conditions 722fec34aSEd Schouten * are met: 822fec34aSEd Schouten * 1. Redistributions of source code must retain the above copyright 922fec34aSEd Schouten * notice, this list of conditions and the following disclaimer. 1022fec34aSEd Schouten * 2. Redistributions in binary form must reproduce the above copyright 1122fec34aSEd Schouten * notice, this list of conditions and the following disclaimer in the 1222fec34aSEd Schouten * documentation and/or other materials provided with the distribution. 13fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 1422fec34aSEd Schouten * may be used to endorse or promote products derived from this software 1522fec34aSEd Schouten * without specific prior written permission. 1622fec34aSEd Schouten * 1722fec34aSEd Schouten * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1822fec34aSEd Schouten * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1922fec34aSEd Schouten * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2022fec34aSEd Schouten * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2122fec34aSEd Schouten * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2222fec34aSEd Schouten * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2322fec34aSEd Schouten * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2422fec34aSEd Schouten * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2522fec34aSEd Schouten * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2622fec34aSEd Schouten * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2722fec34aSEd Schouten * SUCH DAMAGE. 2822fec34aSEd Schouten */ 2922fec34aSEd Schouten 3022fec34aSEd Schouten #include <sys/cdefs.h> 3122fec34aSEd Schouten __FBSDID("$FreeBSD$"); 3222fec34aSEd Schouten 3322fec34aSEd Schouten #include <sys/param.h> 3422fec34aSEd Schouten #include <sys/libkern.h> 3522fec34aSEd Schouten 3622fec34aSEd Schouten char * 3722fec34aSEd Schouten strchr(const char *p, int ch) 3822fec34aSEd Schouten { 3922fec34aSEd Schouten union { 4022fec34aSEd Schouten const char *cp; 4122fec34aSEd Schouten char *p; 4222fec34aSEd Schouten } u; 4322fec34aSEd Schouten 4422fec34aSEd Schouten u.cp = p; 4522fec34aSEd Schouten for (;; ++u.p) { 4622fec34aSEd Schouten if (*u.p == ch) 4722fec34aSEd Schouten return(u.p); 4822fec34aSEd Schouten if (*u.p == '\0') 4922fec34aSEd Schouten return(NULL); 5022fec34aSEd Schouten } 5122fec34aSEd Schouten /* NOTREACHED */ 5222fec34aSEd Schouten } 53