summaryrefslogtreecommitdiff
path: root/lib/libc/string/strspn.c
blob: afbfabe8f40397d4a3e9fe2d9b8066e83a2fa01c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "stddef.h" // for NULL

#include <string.h> // for size_t, strchr, strspn

size_t strspn(const char *s1, const char *s2)
{
	size_t count = 0;
	while (*s1 != '\0' && strchr(s2, *s1) != NULL) {
		count++;
		s1++;
	}
	return count;
}