142151Sbostic /*- 2*61193Sbostic * Copyright (c) 1990, 1993 3*61193Sbostic * The Regents of the University of California. All rights reserved. 434479Sbostic * 542151Sbostic * This code is derived from software contributed to Berkeley by 642151Sbostic * Chris Torek. 742151Sbostic * 842151Sbostic * %sccs.include.redist.c% 924192Skre */ 1024192Skre 1126534Sdonn #if defined(LIBC_SCCS) && !defined(lint) 12*61193Sbostic static char sccsid[] = "@(#)strcspn.c 8.1 (Berkeley) 06/04/93"; 1334479Sbostic #endif /* LIBC_SCCS and not lint */ 1424192Skre 1546144Sbostic #include <sys/cdefs.h> 1642151Sbostic #include <string.h> 1742151Sbostic 1842151Sbostic /* 1942151Sbostic * Span the complement of string s2. 2042151Sbostic */ 2142151Sbostic size_t strcspn(s1,s2)2242151Sbosticstrcspn(s1, s2) 2342151Sbostic const char *s1; 2442151Sbostic register const char *s2; 2524192Skre { 2642151Sbostic register const char *p, *spanp; 2742151Sbostic register char c, sc; 2824192Skre 2942151Sbostic /* 3042151Sbostic * Stop as soon as we find any character from s2. Note that there 3142151Sbostic * must be a NUL in s2; it suffices to stop when we find that, too. 3242151Sbostic */ 3342151Sbostic for (p = s1;;) { 3442151Sbostic c = *p++; 3542151Sbostic spanp = s2; 3642151Sbostic do { 3742151Sbostic if ((sc = *spanp++) == c) 3842151Sbostic return (p - 1 - s1); 3942151Sbostic } while (sc != 0); 4024192Skre } 4142151Sbostic /* NOTREACHED */ 4224192Skre } 43