xref: /original-bsd/lib/libc/string/strspn.c (revision 03a7be21)
1 /*
2  * Copyright (c) 1985 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific written prior permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12 
13 #if defined(LIBC_SCCS) && !defined(lint)
14 static char sccsid[] = "@(#)strspn.c	5.3 (Berkeley) 05/25/88";
15 #endif /* LIBC_SCCS and not lint */
16 
17 strspn(s, set)
18 	register char *s, *set;
19 {
20 	register n = 0;
21 	register char *p;
22 	register c;
23 
24 	while (c = *s++) {
25 		for (p = set; *p; p++)
26 			if (c == *p)
27 				break;
28 		if (!*p)
29 			return (n);
30 		n++;
31 	}
32 	return (n);
33 }
34