xref: /csrg-svn/lib/libc/string/strspn.c (revision 34831)
124190Skre /*
224190Skre  * Copyright (c) 1985 Regents of the University of California.
334479Sbostic  * All rights reserved.
434479Sbostic  *
534479Sbostic  * Redistribution and use in source and binary forms are permitted
6*34831Sbostic  * provided that the above copyright notice and this paragraph are
7*34831Sbostic  * duplicated in all such forms and that any documentation,
8*34831Sbostic  * advertising materials, and other materials related to such
9*34831Sbostic  * distribution and use acknowledge that the software was developed
10*34831Sbostic  * by the University of California, Berkeley.  The name of the
11*34831Sbostic  * University may not be used to endorse or promote products derived
12*34831Sbostic  * from this software without specific prior written permission.
13*34831Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*34831Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*34831Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1624190Skre  */
1724190Skre 
1826537Sdonn #if defined(LIBC_SCCS) && !defined(lint)
19*34831Sbostic static char sccsid[] = "@(#)strspn.c	5.4 (Berkeley) 06/27/88";
2034479Sbostic #endif /* LIBC_SCCS and not lint */
2124190Skre 
2224190Skre strspn(s, set)
2324190Skre 	register char *s, *set;
2424190Skre {
2524190Skre 	register n = 0;
2624190Skre 	register char *p;
2724190Skre 	register c;
2824190Skre 
2924190Skre 	while (c = *s++) {
3024190Skre 		for (p = set; *p; p++)
3124190Skre 			if (c == *p)
3224190Skre 				break;
3324190Skre 		if (!*p)
3424190Skre 			return (n);
3524190Skre 		n++;
3624190Skre 	}
3724190Skre 	return (n);
3824190Skre }
39