xref: /csrg-svn/lib/libc/string/strcspn.c (revision 34479)
124192Skre /*
224192Skre  * 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.
1124192Skre  */
1224192Skre 
1326534Sdonn #if defined(LIBC_SCCS) && !defined(lint)
14*34479Sbostic static char sccsid[] = "@(#)strcspn.c	5.3 (Berkeley) 05/25/88";
15*34479Sbostic #endif /* LIBC_SCCS and not lint */
1624192Skre 
1724192Skre strcspn(s, set)
1824192Skre 	register char *s, *set;
1924192Skre {
2024192Skre 	register n = 0;
2124192Skre 	register char *p;
2224192Skre 	register c;
2324192Skre 
2424192Skre 	while (c = *s++) {
2524192Skre 		for (p = set; *p; p++)
2624192Skre 			if (c == *p)
2724192Skre 				break;
2824192Skre 		if (*p)
2924192Skre 			return (n);
3024192Skre 		n++;
3124192Skre 	}
3224192Skre 	return (n);
3324192Skre }
34