diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-06-01 16:31:08 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-06-01 16:31:08 +0000 |
commit | 06777c5b96ee377bb96e067effce5ca0ad1d3fa8 (patch) | |
tree | 806163dbb5a97f07dadc3acd432d4566fac65769 /libc | |
parent | 75b012d74e1c0be94d4ea16f4d74ad620fc7bb34 (diff) |
decouple this from strchr
Diffstat (limited to 'libc')
-rw-r--r-- | libc/string/strcspn.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/libc/string/strcspn.c b/libc/string/strcspn.c index b383b559a..4b698b55e 100644 --- a/libc/string/strcspn.c +++ b/libc/string/strcspn.c @@ -22,13 +22,17 @@ which contains no characters from REJECT. */ size_t strcspn( const char *s, const char *reject) { - size_t count = 0; + register char *scan1; + register char *scan2; + size_t int count; - while (*s != '\0') - if (strchr(reject, *s++) == NULL) - ++count; - else - return count; - - return count; + count = 0; + for (scan1 = s; *scan1 != '\0'; scan1++) { + for (scan2 = reject; *scan2 != '\0';) /* ++ moved down. */ + if (*scan1 == *scan2++) + return(count); + count++; + } + return(count); } + |