/* * strspn() - Return the span over string a of characters * in string b; e.g., the span consisting only of characters * in b. * * Dan Cross */ #include #include size_t strspn(const char *a, const char *b) { char *p; /* * The precondition checks below, while probably a good * idea, aren't compatible with the rest of the world. * Hence, we disable them to avoid introducing * incompatibilities due to reliance on unspecified behavior. */ /* if (a == NULL) return(0); if (b == NULL) return(strlen(a)); */ for (p = (char *)a; *p != '\0'; p++) if (strchr(b, *p) == NULL) break; return(p - a); }