shithub: mc

Download patch

ref: 3a496c143eb8aad32c03c7067c54807256949c97
parent: 26d2752901f380a5ea22935f49e58e29f404a54a
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Jan 8 19:46:01 EST 2016

Don't attach wildcards *AFTER* accept nodes.

--- a/mi/match.c
+++ b/mi/match.c
@@ -34,7 +34,6 @@
 	/* captured variables and action */
 	Node **cap;
 	size_t ncap;
-
 };
 
 Dtree *gendtree(Node *m, Node *val, Node **lbl, size_t nlbl);
@@ -227,7 +226,7 @@
 	size_t i;
 	int ret;
 
-	if (t->any == accept)
+	if (t->accept || t->any == accept)
 		return 0;
 
 	ret = 0;
@@ -257,7 +256,7 @@
 	ntail = 0;
 	ty = tybase(ty);
 	if (istyprimitive(ty) || ty->type == Tyvoid) {
-		if (start == accept)
+		if (start->accept || start == accept)
 			return 0;
 		for (i = 0; i < start->nnext; i++)
 			lappend(end, nend, start->next[i]);
@@ -567,19 +566,14 @@
 		tail = NULL;
 		ntail = 0;
 
+		/* add a _ capture if we don't specify the value */
 		if (!memb) {
 			memb = mkexpr(ty->sdecls[i]->loc, Ogap, NULL);
 			memb->expr.type = mty;
 		}
 		for (j = 0; j < nlast; j++) {
-			/* add a _ capture if we don't specify the value */
-			if (!memb) {
-				if (addwild(memb, NULL, last[j], next, NULL, NULL, &tail, &ntail))
-					ret = 1;
-			} else {
-				if (addpat(memb, structmemb(val, name, mty), last[j], next, cap, ncap, &tail, &ntail))
-					ret = 1;
-			}
+			if (addpat(memb, structmemb(val, name, mty), last[j], next, cap, ncap, &tail, &ntail))
+				ret = 1;
 		}
 		lfree(&last, &nlast);
 		last = tail;
--- a/mk/c.mk
+++ b/mk/c.mk
@@ -9,7 +9,7 @@
 _LIBPATHS=$(addprefix -l, $(patsubst lib%.a,%,$(notdir $(DEPS)))) $(_PCLIBS)
 
 # yeah, I should probably remove -Werror, but it's nice for developing alone.
-CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-array-bounds -g
+CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-array-bounds -g -O0
 CFLAGS += -MMD -MP -MF .deps/$(subst /,-,$*).d
 
 LIB ?= $(INSTLIB)