xref: /csrg-svn/lib/libc/string/strspn.c (revision 42637)
124190Skre /*
242190Sbostic  * Copyright (c) 1989 The Regents of the University of California.
334479Sbostic  * All rights reserved.
434479Sbostic  *
5*42637Sbostic  * %sccs.include.redist.c%
624190Skre  */
724190Skre 
826537Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*42637Sbostic static char sccsid[] = "@(#)strspn.c	5.7 (Berkeley) 06/01/90";
1034479Sbostic #endif /* LIBC_SCCS and not lint */
1124190Skre 
1242190Sbostic #include <sys/stdc.h>
1342181Sbostic #include <string.h>
1442181Sbostic 
1542190Sbostic /*
1642190Sbostic  * Span the string s2 (skip characters that are in s2).
1742190Sbostic  */
1842190Sbostic size_t
1942190Sbostic strspn(s1, s2)
2042190Sbostic 	const char *s1;
2142190Sbostic 	register const char *s2;
2224190Skre {
2342190Sbostic 	register const char *p = s1, *spanp;
2442190Sbostic 	register char c, sc;
2524190Skre 
2642190Sbostic 	/*
2742190Sbostic 	 * Skip any characters in s2, excluding the terminating \0.
2842190Sbostic 	 */
2942190Sbostic cont:
3042190Sbostic 	c = *p++;
3142190Sbostic 	for (spanp = s2; (sc = *spanp++) != 0;)
3242190Sbostic 		if (sc == c)
3342190Sbostic 			goto cont;
3442190Sbostic 	return (p - 1 - s1);
3524190Skre }
36