1246766Szeising/*-
2246766Szeising * Copyright (c) 2013 Niclas Zeising
3246766Szeising * All rights reserved.
4246766Szeising *
5246766Szeising * Redistribution and use in source and binary forms, with or without
6246766Szeising * modification, are permitted provided that the following conditions
7246766Szeising * are met:
8246766Szeising * 1. Redistributions of source code must retain the above copyright
9246766Szeising *    notice, this list of conditions and the following disclaimer.
10246766Szeising * 2. Redistributions in binary form must reproduce the above copyright
11246766Szeising *    notice, this list of conditions and the following disclaimer in the
12246766Szeising *    documentation and/or other materials provided with the distribution.
13246766Szeising *
14246766Szeising * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15246766Szeising * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16246766Szeising * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17246766Szeising * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18246766Szeising * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19246766Szeising * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20246766Szeising * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21246766Szeising * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22246766Szeising * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23246766Szeising * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24246766Szeising * SUCH DAMAGE.
25246766Szeising *
26246766Szeising */
27246766Szeising
28246766Szeising#include <sys/cdefs.h>
29246766Szeising__FBSDID("$FreeBSD: releng/10.3/lib/libc/string/strchrnul.c 246766 2013-02-13 15:46:33Z zeising $");
30246766Szeising
31246766Szeising#include <stddef.h>
32246766Szeising#include <string.h>
33246766Szeising
34246766Szeising__weak_reference(__strchrnul, strchrnul);
35246766Szeising
36246766Szeisingchar *
37246766Szeising__strchrnul(const char *p, int ch)
38246766Szeising{
39246766Szeising	char c;
40246766Szeising
41246766Szeising	c = ch;
42246766Szeising	for (;; ++p) {
43246766Szeising		if (*p == c || *p == '\0')
44246766Szeising			return ((char *)p);
45246766Szeising	}
46246766Szeising	/* NOTREACHED */
47246766Szeising}
48246766Szeising
49