Commit | Line | Data |
---|---|---|
413c649f | 1 | /* |
0b883867 | 2 | * Copyright (c) 1989 The Regents of the University of California. |
317e5946 KB |
3 | * All rights reserved. |
4 | * | |
019bea33 | 5 | * %sccs.include.redist.c% |
413c649f RE |
6 | */ |
7 | ||
2ce81398 | 8 | #if defined(LIBC_SCCS) && !defined(lint) |
019bea33 | 9 | static char sccsid[] = "@(#)strspn.c 5.7 (Berkeley) %G%"; |
317e5946 | 10 | #endif /* LIBC_SCCS and not lint */ |
413c649f | 11 | |
0b883867 | 12 | #include <sys/stdc.h> |
336401ac KB |
13 | #include <string.h> |
14 | ||
0b883867 KB |
15 | /* |
16 | * Span the string s2 (skip characters that are in s2). | |
17 | */ | |
18 | size_t | |
19 | strspn(s1, s2) | |
20 | const char *s1; | |
21 | register const char *s2; | |
413c649f | 22 | { |
0b883867 KB |
23 | register const char *p = s1, *spanp; |
24 | register char c, sc; | |
413c649f | 25 | |
0b883867 KB |
26 | /* |
27 | * Skip any characters in s2, excluding the terminating \0. | |
28 | */ | |
29 | cont: | |
30 | c = *p++; | |
31 | for (spanp = s2; (sc = *spanp++) != 0;) | |
32 | if (sc == c) | |
33 | goto cont; | |
34 | return (p - 1 - s1); | |
413c649f | 35 | } |