wcsspn.c revision 188080
1195801Smav/*- 2195801Smav * Copyright (c)1999 Citrus Project, 3195801Smav * All rights reserved. 4195801Smav * 5195801Smav * Redistribution and use in source and binary forms, with or without 6195801Smav * modification, are permitted provided that the following conditions 7195801Smav * are met: 8195801Smav * 1. Redistributions of source code must retain the above copyright 9195801Smav * notice, this list of conditions and the following disclaimer. 10195801Smav * 2. Redistributions in binary form must reproduce the above copyright 11195801Smav * notice, this list of conditions and the following disclaimer in the 12195801Smav * documentation and/or other materials provided with the distribution. 13195801Smav * 14195801Smav * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15195801Smav * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16195801Smav * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17195801Smav * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18195801Smav * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19195801Smav * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20195801Smav * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21195801Smav * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22195801Smav * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23195801Smav * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24195801Smav * SUCH DAMAGE. 25195801Smav * 26195801Smav * citrus Id: wcsspn.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp 27195801Smav */ 28195801Smav 29195801Smav#include <sys/cdefs.h> 30195801Smav#if 0 31195801Smav#if defined(LIBC_SCCS) && !defined(lint) 32195801Smav__RCSID("$NetBSD: wcsspn.c,v 1.1 2000/12/23 23:14:37 itojun Exp $"); 33195801Smav#endif /* LIBC_SCCS and not lint */ 34195801Smav#endif 35195801Smav__FBSDID("$FreeBSD: head/lib/libc/string/wcsspn.c 188080 2009-02-03 17:58:20Z danger $"); 36195801Smav 37195801Smav#include <wchar.h> 38195801Smav 39195801Smavsize_t 40195801Smavwcsspn(const wchar_t *s, const wchar_t *set) 41195801Smav{ 42195801Smav const wchar_t *p; 43195801Smav const wchar_t *q; 44195801Smav 45195801Smav p = s; 46195801Smav while (*p) { 47195801Smav q = set; 48195801Smav while (*q) { 49195801Smav if (*p == *q) 50195801Smav break; 51195801Smav q++; 52195801Smav } 53195801Smav if (!*q) 54195801Smav goto done; 55195801Smav p++; 56195801Smav } 57195801Smav 58195801Smavdone: 59195801Smav return (p - s); 60195801Smav} 61195801Smav