1 /*
2 * Copyright (C) 1991, 1992 Linus Torvalds
3 */
4
5 #include <xen/string.h>
6
7 /**
8 * strspn - Calculate the length of the initial substring of @s which only
9 * contain letters in @accept
10 * @s: The string to be searched
11 * @accept: The string to search for
12 */
strspn(const char * s,const char * accept)13 size_t strspn(const char *s, const char *accept)
14 {
15 const char *p;
16 const char *a;
17 size_t count = 0;
18
19 for (p = s; *p != '\0'; ++p) {
20 for (a = accept; *a != '\0'; ++a) {
21 if (*p == *a)
22 break;
23 }
24 if (*a == '\0')
25 return count;
26 ++count;
27 }
28
29 return count;
30 }
31
32 /*
33 * Local variables:
34 * mode: C
35 * c-file-style: "BSD"
36 * c-basic-offset: 8
37 * tab-width: 8
38 * indent-tabs-mode: t
39 * End:
40 */
41