shithub: spread

Download patch

ref: 1322210e058aee6327c77ea4acf8779d6620682f
parent: 7e3533cf6041b0c950a0161c11f391617f1aa21d
author: sirjofri <sirjofri@sirjofri.de>
date: Fri Jul 5 10:14:06 EDT 2024

add empty values for dependencies

--- a/cells.c
+++ b/cells.c
@@ -17,6 +17,18 @@
 
 Reprog *funcregexp;
 
+static char* findvaluep(char *s, P *p);
+
+static void
+addempty(char *s)
+{
+	P p;
+	
+	while (s = findvaluep(s, &p)) {
+		addcell(p, strdup("0"), FUNCTION);
+	}
+}
+
 void
 addcell(P cell, char *value, int type)
 {
@@ -37,6 +49,7 @@
 			free(c->value);
 		c->value = strdup(value);
 		c->type = type;
+		addempty(value);
 		return;
 	}
 	
@@ -50,6 +63,7 @@
 	c->p = cell;
 	c->value = strdup(value);
 	c->type = type;
+	addempty(value);
 }
 
 void
@@ -108,6 +122,9 @@
 {
 	Resub match;
 	
+	if (!funcregexp)
+		funcregexp = regcomp("[A-Z]+[0-9]+[(]+[)]+");
+	
 	memset(&match, 0, sizeof(Resub));
 	if (regexec(funcregexp, s, &match, 1)) {
 		*p = atop(match.sp);
@@ -219,9 +236,7 @@
 	P p;
 	
 	// build DAG information
-	funcregexp = regcomp("[A-Z]+[0-9]+[(]+[)]+");
 	foreachcell(celldeps, nil);
-	free(funcregexp);
 	funcregexp = nil;
 	
 	b.size = block.size;