1 // Copyright 2016 The Fuchsia Authors
2 // Copyright (c) 2008 Travis Geiselbrecht
3 //
4 // Use of this source code is governed by a MIT-style
5 // license that can be found in the LICENSE file or at
6 // https://opensource.org/licenses/MIT
7 
8 #include <string.h>
9 #include <sys/types.h>
10 
11 size_t
strspn(char const * s,char const * accept)12 strspn(char const *s, char const *accept)
13 {
14     const char *p;
15     const char *a;
16     size_t count = 0;
17 
18     for (p = s; *p != '\0'; ++p) {
19         for (a = accept; *a != '\0'; ++a) {
20             if (*p == *a)
21                 break;
22         }
23         if (*a == '\0')
24             return count;
25         ++count;
26     }
27 
28     return count;
29 }
30