1 /* 2 ** Copyright 2001, Travis Geiselbrecht. All rights reserved. 3 ** Distributed under the terms of the NewOS License. 4 */ 5 6 #include <sys/types.h> 7 #include <string.h> 8 9 10 size_t 11 strspn(char const *s, char const *accept) 12 { 13 const char *p; 14 const char *a; 15 size_t count = 0; 16 17 for (p = s; *p != '\0'; ++p) { 18 for (a = accept; *a != '\0'; ++a) { 19 if (*p == *a) 20 break; 21 } 22 if (*a == '\0') 23 return count; 24 ++count; 25 } 26 27 return count; 28 } 29