shithub: scc

ref: 5310badb8f39560835f0db678d6784217c92766f
dir: /lib/c/strcspn.c/

View raw version
#include <string.h>
#undef strcspn

size_t
strcspn(const char *s1, const char *s2)
{
	char buf[256];
	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;
}