xref: /plan9-contrib/sys/src/ape/lib/ap/gen/strspn.c (revision ec59a3ddbfceee0efe34584c2c9981a5e5ff1ec4)
1 #include <string.h>
2 
3 #define	N	256
4 
5 size_t
6 strspn(const char *s, const char *b)
7 {
8 	char map[N], *os;
9 
10 	memset(map, 0, N);
11 	while(*b)
12 		map[*(unsigned char *)b++] = 1;
13 	os = s;
14 	while(map[*(unsigned char *)s++])
15 		;
16 	return s - os - 1;
17 }
18