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