summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-12-26 15:20:26 -0800
committerOri Bernstein <ori@eigenstate.org>2014-12-26 15:20:26 -0800
commit14f1055a8f6709a4740ae23cde2e72e45327fcfc (patch)
tree77e20e91ec4d9b2e9038b708d22c4f3c0e108a8f
parent8dc4d709e1bf60d8d82915d14ef506e1cdd4123d (diff)
downloadmc-14f1055a8f6709a4740ae23cde2e72e45327fcfc.tar.gz
Don't use subexpressions that don't exist.
-rw-r--r--mi/match.c12
-rw-r--r--mkfile4
2 files changed, 12 insertions, 4 deletions
diff --git a/mi/match.c b/mi/match.c
index c644afc..be0e033 100644
--- a/mi/match.c
+++ b/mi/match.c
@@ -21,7 +21,7 @@ struct Dtree {
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 @@ static Dtree *addunion(Dtree *t, Node *pat, Node *val, Node ***cap, size_t *ncap
/* 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 @@ static Dtree *addlit(Dtree *t, Node *pat, Node *val, Node ***cap, size_t *ncap)
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();
diff --git a/mkfile b/mkfile
index 2a580b6..748d1e0 100644
--- a/mkfile
+++ b/mkfile
@@ -40,6 +40,10 @@ uninstall:V: $SUB config.h
mk $MKFLAGS
}
+check:V:
+ cd test
+ mk check
+
config.h:
echo '#define Instroot "/amd64"' > config.h
echo '#define Asmcmd {"6a", "-o", NULL}' >> config.h