commit f02ae1eb9ac2ebb1f12566363df5182e91d3b11b
parent c43717c93453db5e25ba33dcbdad7112f7cb5b0c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 12 Sep 2018 07:17:38 +0100
Merge branch 'master' of ssh://simple-cc.org:/var/gitrepos/scc
Diffstat:
3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/lib/c/abort.c b/lib/c/abort.c
@@ -1,6 +1,5 @@
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#undef abort
diff --git a/lib/c/strcspn.c b/lib/c/strcspn.c
@@ -4,15 +4,16 @@
size_t
strcspn(const char *s1, const char *s2)
{
+ char buf[256];
+ unsigned char ch;
size_t n;
- int c;
- const char *p;
- for (n = 0; c = *s1++; ++n) {
- for (p = s2; *p && *p != c; ++p)
- ;
- if (*p == c)
- break;
- }
+ memset(buf, 0, sizeof(buf));
+ while (ch = *s2++)
+ buf[ch] = 1;
+
+ for (n = 0; (ch = *s1++) && !buf[ch]; ++n)
+ ;
+
return n;
}
diff --git a/lib/c/strspn.c b/lib/c/strspn.c
@@ -4,15 +4,16 @@
size_t
strspn(const char *s1, const char *s2)
{
+ char buf[256];
+ unsigned char ch;
size_t n;
- int c;
- const char *p;
- for (n = 0; c = *s1++; ++n) {
- for (p = s2; *p && *p != c; ++p)
- ;
- if (*p == '\0')
- break;
- }
+ memset(buf, 0, sizeof(buf));
+ while (ch = *s2++)
+ buf[ch] = 1;
+
+ for (n = 0; (ch = *s1++) && buf[ch]; ++n)
+ ;
+
return n;
}