summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2009-11-11 00:12:11 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2009-11-11 00:12:11 +0000
commit5db91da9805ee015db1db9f8f352af0d211cfc7f (patch)
treed7087d168149e25e37bcd86297100c867bdda134 /usr.bin/make
parentb7a9969813ce8c8fa03181f315dc859eda7a5e75 (diff)
If this is an else-type conditional and previous corresponding one
evaluated to true, skip. tested by simon@ and myself. espie@ ok.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/cond.c55
1 files changed, 23 insertions, 32 deletions
diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c
index eab4e96262a..9b572842ee6 100644
--- a/usr.bin/make/cond.c
+++ b/usr.bin/make/cond.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: cond.c,v 1.40 2008/11/24 16:23:04 espie Exp $ */
+/* $OpenBSD: cond.c,v 1.41 2009/11/11 00:12:10 fgsch Exp $ */
/* $NetBSD: cond.c,v 1.7 1996/11/06 17:59:02 christos Exp $ */
/*
@@ -1045,11 +1045,13 @@ Cond_Eval(const char *line)
if (condTop == MAXIF) {
Parse_Error(level, "if-less elif");
return COND_INVALID;
- } else if (skipIfLevel != 0) {
- /* If skipping this conditional, just ignore the whole
- * thing. If we don't, the user might be employing a
- * variable that's undefined, for which there's an
- * enclosing ifdef that we're skipping... */
+ } else if (skipIfLevel != 0 || condStack[condTop].value) {
+ /*
+ * Skip if we're meant to or is an else-type
+ * conditional and previous corresponding one was
+ * evaluated to true.
+ */
+ skipLine = true;
return COND_SKIP;
}
} else if (skipLine) {
@@ -1057,6 +1059,16 @@ Cond_Eval(const char *line)
* if we're skipping things... */
skipIfLevel++;
return COND_SKIP;
+ } else
+ condTop--;
+
+ if (condTop < 0) {
+ /* This is the one case where we can definitely proclaim a fatal
+ * error. If we don't, we're hosed. */
+ Parse_Error(PARSE_FATAL, "Too many nested if's. %d max.",
+ MAXIF);
+ condTop = 0;
+ return COND_INVALID;
}
if (ifp->defProc) {
@@ -1095,32 +1107,11 @@ err:
}
}
- if (!ifp->isElse)
- condTop--;
- else if (skipIfLevel != 0 || condStack[condTop].value) {
- /* If this is an else-type conditional, it should only take
- * effect if its corresponding if was evaluated and false. If
- * its if was true or skipped, we return COND_SKIP (and start
- * skipping in case we weren't already), leaving the stack
- * unmolested so later elif's don't screw up... */
- skipLine = true;
- return COND_SKIP;
- }
-
- if (condTop < 0) {
- /* This is the one case where we can definitely proclaim a fatal
- * error. If we don't, we're hosed. */
- Parse_Error(PARSE_FATAL, "Too many nested if's. %d max.",
- MAXIF);
- condTop = 0;
- return COND_INVALID;
- } else {
- condStack[condTop].value = value;
- condStack[condTop].lineno = Parse_Getlineno();
- condStack[condTop].filename = Parse_Getfilename();
- skipLine = !value;
- return value ? COND_PARSE : COND_SKIP;
- }
+ condStack[condTop].value = value;
+ condStack[condTop].lineno = Parse_Getlineno();
+ condStack[condTop].filename = Parse_Getfilename();
+ skipLine = !value;
+ return value ? COND_PARSE : COND_SKIP;
}
void