=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/cond.c,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- src/usr.bin/make/cond.c 2008/11/24 16:23:04 1.40 +++ src/usr.bin/make/cond.c 2009/11/11 00:12:10 1.41 @@ -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 @@ 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 @@ * 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 @@ } } - 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