From 06777c5b96ee377bb96e067effce5ca0ad1d3fa8 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 1 Jun 2001 16:31:08 +0000 Subject: decouple this from strchr --- libc/string/strcspn.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'libc') 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); } + -- cgit v1.2.3