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