xref: /original-bsd/lib/libc/string/strspn.c (revision 4cda19ca)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)strspn.c	5.8 (Berkeley) 01/26/91";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <sys/cdefs.h>
13 #include <string.h>
14 
15 /*
16  * Span the string s2 (skip characters that are in s2).
17  */
18 size_t
19 strspn(s1, s2)
20 	const char *s1;
21 	register const char *s2;
22 {
23 	register const char *p = s1, *spanp;
24 	register char c, sc;
25 
26 	/*
27 	 * Skip any characters in s2, excluding the terminating \0.
28 	 */
29 cont:
30 	c = *p++;
31 	for (spanp = s2; (sc = *spanp++) != 0;)
32 		if (sc == c)
33 			goto cont;
34 	return (p - 1 - s1);
35 }
36