xref: /freebsd/lib/libc/string/strchr.c (revision 559a218c9b257775fb249b67945fe4a05b7a6b9f)
146632c18SEd Schouten /*-
2*7f72497eSEd Maste  * SPDX-License-Identifier: MIT
38a16b7a1SPedro F. Giffuni  *
4*7f72497eSEd Maste  * Copyright (c) 2005-2014 Rich Felker, et al.
546632c18SEd Schouten  *
6*7f72497eSEd Maste  * Permission is hereby granted, free of charge, to any person obtaining
7*7f72497eSEd Maste  * a copy of this software and associated documentation files (the
8*7f72497eSEd Maste  * "Software"), to deal in the Software without restriction, including
9*7f72497eSEd Maste  * without limitation the rights to use, copy, modify, merge, publish,
10*7f72497eSEd Maste  * distribute, sublicense, and/or sell copies of the Software, and to
11*7f72497eSEd Maste  * permit persons to whom the Software is furnished to do so, subject to
12*7f72497eSEd Maste  * the following conditions:
1346632c18SEd Schouten  *
14*7f72497eSEd Maste  * The above copyright notice and this permission notice shall be
15*7f72497eSEd Maste  * included in all copies or substantial portions of the Software.
16*7f72497eSEd Maste  *
17*7f72497eSEd Maste  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18*7f72497eSEd Maste  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19*7f72497eSEd Maste  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20*7f72497eSEd Maste  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21*7f72497eSEd Maste  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22*7f72497eSEd Maste  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23*7f72497eSEd Maste  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2446632c18SEd Schouten  */
2546632c18SEd Schouten #include <string.h>
2646632c18SEd Schouten 
27*7f72497eSEd Maste char *__strchrnul(const char *, int);
2846632c18SEd Schouten 
29*7f72497eSEd Maste char *
strchr(const char * s,int c)30*7f72497eSEd Maste strchr(const char *s, int c)
31*7f72497eSEd Maste {
32*7f72497eSEd Maste 	char *r = __strchrnul(s, c);
33*7f72497eSEd Maste 	return *(unsigned char *)r == (unsigned char)c ? r : NULL;
3446632c18SEd Schouten }
3546632c18SEd Schouten 
3619c262feSEd Schouten __weak_reference(strchr, index);
37