summaryrefslogtreecommitdiff
path: root/libc/string/strcspn.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/string/strcspn.c')
-rw-r--r--libc/string/strcspn.c20
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);
}
+