1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *  Copyright (C) 1991, 1992  Linus Torvalds
4  */
5 
6 #include <xen/string.h>
7 
8 /**
9  * strcspn - Calculate the length of the initial substring of @s which does not contain letters in @reject
10  * @s: The string to be searched
11  * @reject: The string to avoid
12  */
size_t(strcspn)13 size_t (strcspn)(const char *s, const char *reject)
14 {
15        const char *p;
16 
17        for (p = s; *p != '\0'; ++p) {
18                if (strchr(reject, *p))
19                        break;
20        }
21        return p - s;
22 }
23