shithub: scc

Download patch

ref: 5310badb8f39560835f0db678d6784217c92766f
parent: bdcf59621848c43fda1bf636ba03ed8007fdb924
parent: e15a440b400655c6457fd2486c9636bd53419631
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Sep 12 03:17:38 EDT 2018

Merge branch 'master' of ssh://simple-cc.org:/var/gitrepos/scc

--- 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
 
--- 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;
 }
--- 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;
 }