scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 2bfb5f5576e1723e10aebaaed7476e3608941c1e
parent 44a3fd53a73262f822613097d7b6a01c70320ba3
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 16 Sep 2018 06:56:04 +0100

[lib/c] Support only charset between 0-127

Diffstat:
Mlib/c/strcspn.c | 2+-
Mlib/c/strpbrk.c | 19++++++++++---------
Mlib/c/strspn.c | 2+-
3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/c/strcspn.c b/lib/c/strcspn.c @@ -4,7 +4,7 @@ size_t strcspn(const char *s1, const char *s2) { - char buf[256]; + char buf[128]; unsigned char ch; size_t n; diff --git a/lib/c/strpbrk.c b/lib/c/strpbrk.c @@ -4,14 +4,15 @@ char * strpbrk(const char *s1, const char *s2) { - int c; - const char *p; + char buf[128]; + unsigned ch; - for (; c = *s1; ++s1) { - for (p = s2; *p && *p != c; ++p) - ; - if (*p == c) - return (char *) s1; - } - return NULL; + memset(buf, 0, sizeof(buf)); + while (ch = *s2++) + buf[ch] = 1; + + while ((ch = *s1) && !buf[ch]) + s1++; + + return (ch == '\0') ? NULL : (char *) s1; } diff --git a/lib/c/strspn.c b/lib/c/strspn.c @@ -4,7 +4,7 @@ size_t strspn(const char *s1, const char *s2) { - char buf[256]; + char buf[128]; unsigned char ch; size_t n;