ref: 6041d0a1d135a8085dad7a76ec66dc42151065ab
parent: 11f90555b8eb5452e665aad552557f921df1800a
author: Ori Bernstein <[email protected]>
date: Fri Dec 26 10:20:26 EST 2014
Don't use subexpressions that don't exist.
--- a/mi/match.c
+++ b/mi/match.c
@@ -21,7 +21,7 @@
size_t nval;
Node **load; /* expression value being compared */
size_t nload;
- Dtree **sub; /* submatche to use if if equal */
+ Dtree **sub; /* submatch to use if if equal */
size_t nsub;
Dtree *any; /* tree for a wildcard match. */
@@ -116,8 +116,12 @@
/* if we have the value already... */
sub = NULL;
for (i = 0; i < t->nval; i++) {
- if (nameeq(t->val[i], pat->expr.args[0]))
- return addpat(t->sub[i], pat->expr.args[1], NULL, cap, ncap);
+ if (nameeq(t->val[i], pat->expr.args[0])) {
+ if (pat->expr.nargs > 1)
+ return addpat(t->sub[i], pat->expr.args[1], NULL, cap, ncap);
+ else
+ return t->sub[i];
+ }
}
sub = mkdtree();
@@ -138,7 +142,7 @@
return t->any;
for (i = 0; i < t->nval; i++) {
if (liteq(t->val[i]->expr.args[0], pat->expr.args[0]))
- return addpat(t->sub[i], pat->expr.args[1], NULL, cap, ncap);
+ return t->sub[i];
}
sub = mkdtree();
--- a/mkfile
+++ b/mkfile
@@ -40,6 +40,10 @@
mk $MKFLAGS
}
+check:V:
+ cd test
+ mk check
+
config.h:
echo '#define Instroot "/amd64"' > config.h
echo '#define Asmcmd {"6a", "-o", NULL}' >> config.h