1 /* @(#)wcscspn.c 1.1 14/01/06 Copyright 2014 J. Schilling */ 2 /* 3 * find maximum number of chars in s1 that consists solely of chars 4 * NOT in s2 5 * 6 * Copyright (c) 2014 J. Schilling 7 */ 8 /* 9 * The contents of this file are subject to the terms of the 10 * Common Development and Distribution License, Version 1.0 only 11 * (the "License"). You may not use this file except in compliance 12 * with the License. 13 * 14 * See the file CDDL.Schily.txt in this distribution for details. 15 * A copy of the CDDL is also available via the Internet at 16 * http://www.opensource.org/licenses/cddl1.txt 17 * 18 * When distributing Covered Code, include this CDDL HEADER in each 19 * file and include the License file CDDL.Schily.txt from this distribution. 20 */ 21 #include <schily/standard.h> 22 #include <schily/wchar.h> 23 #include <schily/schily.h> 24 #include <schily/string.h> 25 26 #ifndef HAVE_WCSCSPN 27 28 EXPORT size_t wcscspn(s1,s2)29wcscspn(s1, s2) 30 register const wchar_t *s1; /* The string to search */ 31 const wchar_t *s2; /* The charset used to search */ 32 { 33 register const wchar_t *a; 34 register const wchar_t *b; 35 36 if (*s2 == '\0') 37 return (wcslen(s1)); 38 39 for (a = s1; *a != '\0'; a++) { 40 for (b = s2; *b != '\0' && *a != *b; b++) 41 ; 42 if (*b != '\0') 43 break; 44 } 45 return (a - s1); 46 } 47 48 #endif 49