strspn.c 220 B

123456789101112131415161718
  1. #include <u.h>
  2. #include <libc.h>
  3. #define N 256
  4. long
  5. strspn(char *s, char *b)
  6. {
  7. char map[N], *os;
  8. memset(map, 0, N);
  9. while(*b)
  10. map[*(uchar *)b++] = 1;
  11. os = s;
  12. while(map[*(uchar *)s++])
  13. ;
  14. return s - os - 1;
  15. }