xref: /csrg-svn/lib/libc/string/strspn.c (revision 34479)
124190Skre /*
224190Skre  * Copyright (c) 1985 Regents of the University of California.
3*34479Sbostic  * All rights reserved.
4*34479Sbostic  *
5*34479Sbostic  * Redistribution and use in source and binary forms are permitted
6*34479Sbostic  * provided that this notice is preserved and that due credit is given
7*34479Sbostic  * to the University of California at Berkeley. The name of the University
8*34479Sbostic  * may not be used to endorse or promote products derived from this
9*34479Sbostic  * software without specific written prior permission. This software
10*34479Sbostic  * is provided ``as is'' without express or implied warranty.
1124190Skre  */
1224190Skre 
1326537Sdonn #if defined(LIBC_SCCS) && !defined(lint)
14*34479Sbostic static char sccsid[] = "@(#)strspn.c	5.3 (Berkeley) 05/25/88";
15*34479Sbostic #endif /* LIBC_SCCS and not lint */
1624190Skre 
1724190Skre strspn(s, set)
1824190Skre 	register char *s, *set;
1924190Skre {
2024190Skre 	register n = 0;
2124190Skre 	register char *p;
2224190Skre 	register c;
2324190Skre 
2424190Skre 	while (c = *s++) {
2524190Skre 		for (p = set; *p; p++)
2624190Skre 			if (c == *p)
2724190Skre 				break;
2824190Skre 		if (!*p)
2924190Skre 			return (n);
3024190Skre 		n++;
3124190Skre 	}
3224190Skre 	return (n);
3324190Skre }
34