176612Stshiozak/*- 2105844Stjr * Copyright (c) 1990, 1993 3105844Stjr * The Regents of the University of California. All rights reserved. 476612Stshiozak * 5105844Stjr * This code is derived from software contributed to Berkeley by 6105844Stjr * Chris Torek. 7105844Stjr * 876612Stshiozak * Redistribution and use in source and binary forms, with or without 976612Stshiozak * modification, are permitted provided that the following conditions 1076612Stshiozak * are met: 1176612Stshiozak * 1. Redistributions of source code must retain the above copyright 1276612Stshiozak * notice, this list of conditions and the following disclaimer. 1376612Stshiozak * 2. Redistributions in binary form must reproduce the above copyright 1476612Stshiozak * notice, this list of conditions and the following disclaimer in the 1576612Stshiozak * documentation and/or other materials provided with the distribution. 16251069Semaste * 3. Neither the name of the University nor the names of its contributors 17105844Stjr * may be used to endorse or promote products derived from this software 18105844Stjr * without specific prior written permission. 1976612Stshiozak * 20105844Stjr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2176612Stshiozak * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2276612Stshiozak * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23105844Stjr * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2476612Stshiozak * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2576612Stshiozak * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2676612Stshiozak * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2776612Stshiozak * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2876612Stshiozak * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2976612Stshiozak * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3076612Stshiozak * SUCH DAMAGE. 3176612Stshiozak */ 3276612Stshiozak 3392986Sobrien#if 0 3476612Stshiozak#if defined(LIBC_SCCS) && !defined(lint) 35105844Stjrstatic char sccsid[] = "@(#)strstr.c 8.1 (Berkeley) 6/4/93"; 3676612Stshiozak#endif /* LIBC_SCCS and not lint */ 3792986Sobrien#endif 38105844Stjr#include <sys/cdefs.h> 3986170Sobrien__FBSDID("$FreeBSD$"); 4076612Stshiozak 4176612Stshiozak#include <wchar.h> 4276612Stshiozak 43105844Stjr/* 44105844Stjr * Find the first occurrence of find in s. 45105844Stjr */ 4676612Stshiozakwchar_t * 47105844Stjrwcsstr(const wchar_t * __restrict s, const wchar_t * __restrict find) 4876612Stshiozak{ 49105844Stjr wchar_t c, sc; 50105844Stjr size_t len; 5176612Stshiozak 52188080Sdanger if ((c = *find++) != L'\0') { 53105844Stjr len = wcslen(find); 54105844Stjr do { 55105844Stjr do { 56105844Stjr if ((sc = *s++) == L'\0') 57105844Stjr return (NULL); 58105844Stjr } while (sc != c); 59105844Stjr } while (wcsncmp(s, find, len) != 0); 60105844Stjr s--; 6176612Stshiozak } 62105844Stjr return ((wchar_t *)s); 6376612Stshiozak} 64