ref: ac6ae0f0c282b05d7e8351893bfc49c1e9b3f02c
dir: /lib/c/strcspn.c/
#include <limits.h> #include <string.h> #undef strcspn size_t strcspn(const char *s1, const char *s2) { char buf[sizeof(char) * CHAR_BIT]; unsigned char ch; size_t n; memset(buf, 0, sizeof(buf)); while (ch = *s2++) buf[ch] = 1; for (n = 0; (ch = *s1++) && !buf[ch]; ++n) ; return n; }