xref: /openbsd-src/sys/lib/libsa/strchr.c (revision 0008cc64d9da75254efcbffc71d3c74e5074e90f)
1*0008cc64Sderaadt /*	$OpenBSD: strchr.c,v 1.5 2012/07/13 16:09:49 deraadt Exp $	*/
2404f71c3Smillert 
3404f71c3Smillert /*-
4404f71c3Smillert  * Copyright (c) 1990 The Regents of the University of California.
5404f71c3Smillert  * All rights reserved.
6404f71c3Smillert  *
7404f71c3Smillert  * Redistribution and use in source and binary forms, with or without
8404f71c3Smillert  * modification, are permitted provided that the following conditions
9404f71c3Smillert  * are met:
10404f71c3Smillert  * 1. Redistributions of source code must retain the above copyright
11404f71c3Smillert  *    notice, this list of conditions and the following disclaimer.
12404f71c3Smillert  * 2. Redistributions in binary form must reproduce the above copyright
13404f71c3Smillert  *    notice, this list of conditions and the following disclaimer in the
14404f71c3Smillert  *    documentation and/or other materials provided with the distribution.
1529295d1cSmillert  * 3. Neither the name of the University nor the names of its contributors
16404f71c3Smillert  *    may be used to endorse or promote products derived from this software
17404f71c3Smillert  *    without specific prior written permission.
18404f71c3Smillert  *
19404f71c3Smillert  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20404f71c3Smillert  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21404f71c3Smillert  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22404f71c3Smillert  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23404f71c3Smillert  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24404f71c3Smillert  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25404f71c3Smillert  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26404f71c3Smillert  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27404f71c3Smillert  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28404f71c3Smillert  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29404f71c3Smillert  * SUCH DAMAGE.
30404f71c3Smillert  */
31404f71c3Smillert 
32d6140925Smickey #ifndef _STANDALONE
33404f71c3Smillert #include <string.h>
34404f71c3Smillert #else
35d6140925Smickey #include <lib/libsa/stand.h>
36404f71c3Smillert #endif
37404f71c3Smillert 
38404f71c3Smillert char *
strchr(const char * p,int ch)39599546b3Sderaadt strchr(const char *p, int ch)
40404f71c3Smillert {
41404f71c3Smillert 	for (;; ++p) {
42404f71c3Smillert 		if (*p == ch)
43404f71c3Smillert 			return((char *)p);
44404f71c3Smillert 		if (!*p)
45404f71c3Smillert 			return((char *)NULL);
46404f71c3Smillert 	}
47404f71c3Smillert 	/* NOTREACHED */
48404f71c3Smillert }
49