bug fix: did not handle #elif right

This commit is contained in:
ceriel 1989-05-29 11:11:34 +00:00
parent c1075bd08c
commit 4a1f9bbc22

View file

@ -142,7 +142,7 @@ domacro()
} }
PRIVATE PRIVATE
skip_block() skip_block(to_endif)
{ {
/* skip_block() skips the input from /* skip_block() skips the input from
1) a false #if, #ifdef, #ifndef or #elif until the 1) a false #if, #ifdef, #ifndef or #elif until the
@ -188,7 +188,7 @@ skip_block()
push_if(); push_if();
continue; continue;
case K_ELIF: case K_ELIF:
if (nestlevel == skiplevel) { if (! to_endif && nestlevel == skiplevel) {
nestlevel--; nestlevel--;
push_if(); push_if();
if (ifexpr()) { if (ifexpr()) {
@ -198,12 +198,14 @@ skip_block()
} }
break; break;
case K_ELSE: case K_ELSE:
++(ifstack[nestlevel]); if (! to_endif) {
if (nestlevel == skiplevel) { ++(ifstack[nestlevel]);
PushBack(); if (nestlevel == skiplevel) {
skipline(); PushBack();
NoUnstack--; skipline();
return; NoUnstack--;
return;
}
} }
break; break;
case K_ENDIF: case K_ENDIF:
@ -349,7 +351,7 @@ do_elif()
else { /* restart at this level as if a #if is detected. */ else { /* restart at this level as if a #if is detected. */
nestlevel--; nestlevel--;
push_if(); push_if();
skip_block(); skip_block(1);
} }
} }
@ -362,7 +364,7 @@ do_else()
error("#else without corresponding #if"); error("#else without corresponding #if");
else { /* mark this level as else-d */ else { /* mark this level as else-d */
++(ifstack[nestlevel]); ++(ifstack[nestlevel]);
skip_block(); skip_block(1);
} }
} }
@ -381,7 +383,7 @@ do_if()
{ {
push_if(); push_if();
if (!ifexpr()) /* a false #if/#elif expression */ if (!ifexpr()) /* a false #if/#elif expression */
skip_block(); skip_block(0);
} }
PRIVATE PRIVATE
@ -407,7 +409,7 @@ do_ifdef(how)
(how && !id->id_macro) || (!how && id->id_macro) (how && !id->id_macro) || (!how && id->id_macro)
*/ */
if (how ^ (id && id->id_macro != 0)) if (how ^ (id && id->id_macro != 0))
skip_block(); skip_block(0);
else { else {
PushBack(); PushBack();
skipline(); skipline();