18fd2f243SFrançois Tigeot /*- 28fd2f243SFrançois Tigeot * Copyright (c) 2013 Niclas Zeising 38fd2f243SFrançois Tigeot * All rights reserved. 48fd2f243SFrançois Tigeot * 58fd2f243SFrançois Tigeot * Redistribution and use in source and binary forms, with or without 68fd2f243SFrançois Tigeot * modification, are permitted provided that the following conditions 78fd2f243SFrançois Tigeot * are met: 88fd2f243SFrançois Tigeot * 1. Redistributions of source code must retain the above copyright 98fd2f243SFrançois Tigeot * notice, this list of conditions and the following disclaimer. 108fd2f243SFrançois Tigeot * 2. Redistributions in binary form must reproduce the above copyright 118fd2f243SFrançois Tigeot * notice, this list of conditions and the following disclaimer in the 128fd2f243SFrançois Tigeot * documentation and/or other materials provided with the distribution. 138fd2f243SFrançois Tigeot * 148fd2f243SFrançois Tigeot * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 158fd2f243SFrançois Tigeot * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 168fd2f243SFrançois Tigeot * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 178fd2f243SFrançois Tigeot * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 188fd2f243SFrançois Tigeot * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 198fd2f243SFrançois Tigeot * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 208fd2f243SFrançois Tigeot * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 218fd2f243SFrançois Tigeot * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 228fd2f243SFrançois Tigeot * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 238fd2f243SFrançois Tigeot * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 248fd2f243SFrançois Tigeot * SUCH DAMAGE. 258fd2f243SFrançois Tigeot * 260d5acd74SJohn Marino * $FreeBSD: head/lib/libc/string/strchrnul.c 246766 2013-02-13 15:46:33Z zeising $ 278fd2f243SFrançois Tigeot */ 288fd2f243SFrançois Tigeot 290d5acd74SJohn Marino #include <stddef.h> 308fd2f243SFrançois Tigeot #include <string.h> 318fd2f243SFrançois Tigeot 328fd2f243SFrançois Tigeot char * 330d5acd74SJohn Marino __strchrnul(const char *p, int ch) 348fd2f243SFrançois Tigeot { 358fd2f243SFrançois Tigeot char c; 368fd2f243SFrançois Tigeot 378fd2f243SFrançois Tigeot c = ch; 388fd2f243SFrançois Tigeot for (;; ++p) { 398fd2f243SFrançois Tigeot if (*p == c || *p == '\0') 408fd2f243SFrançois Tigeot return ((char *)p); 418fd2f243SFrançois Tigeot } 428fd2f243SFrançois Tigeot /* NOTREACHED */ 438fd2f243SFrançois Tigeot } 440d5acd74SJohn Marino 45*f8406b33Szrj __weak_reference(__strchrnul, strchrnul); 46