From: ceriel Date: Mon, 29 May 1989 11:11:34 +0000 (+0000) Subject: bug fix: did not handle #elif right X-Git-Tag: release-5-5~2420 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=4a1f9bbc22c414fdea332384b9f9051957477fe5;p=ack.git bug fix: did not handle #elif right --- diff --git a/util/cpp/domacro.c b/util/cpp/domacro.c index 3cdd4dfd4..17027e529 100644 --- a/util/cpp/domacro.c +++ b/util/cpp/domacro.c @@ -142,7 +142,7 @@ domacro() } PRIVATE -skip_block() +skip_block(to_endif) { /* skip_block() skips the input from 1) a false #if, #ifdef, #ifndef or #elif until the @@ -188,7 +188,7 @@ skip_block() push_if(); continue; case K_ELIF: - if (nestlevel == skiplevel) { + if (! to_endif && nestlevel == skiplevel) { nestlevel--; push_if(); if (ifexpr()) { @@ -198,12 +198,14 @@ skip_block() } break; case K_ELSE: - ++(ifstack[nestlevel]); - if (nestlevel == skiplevel) { - PushBack(); - skipline(); - NoUnstack--; - return; + if (! to_endif) { + ++(ifstack[nestlevel]); + if (nestlevel == skiplevel) { + PushBack(); + skipline(); + NoUnstack--; + return; + } } break; case K_ENDIF: @@ -349,7 +351,7 @@ do_elif() else { /* restart at this level as if a #if is detected. */ nestlevel--; push_if(); - skip_block(); + skip_block(1); } } @@ -362,7 +364,7 @@ do_else() error("#else without corresponding #if"); else { /* mark this level as else-d */ ++(ifstack[nestlevel]); - skip_block(); + skip_block(1); } } @@ -381,7 +383,7 @@ do_if() { push_if(); if (!ifexpr()) /* a false #if/#elif expression */ - skip_block(); + skip_block(0); } PRIVATE @@ -407,7 +409,7 @@ do_ifdef(how) (how && !id->id_macro) || (!how && id->id_macro) */ if (how ^ (id && id->id_macro != 0)) - skip_block(); + skip_block(0); else { PushBack(); skipline();