From: ceriel Date: Tue, 27 Jun 1989 11:43:26 +0000 (+0000) Subject: removed some useless PushBack's, and added warnings X-Git-Tag: release-5-5~2364 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=f781103cb48ae55e835fd4934f638d6bba19fcce;p=ack.git removed some useless PushBack's, and added warnings --- diff --git a/util/cpp/LLlex.c b/util/cpp/LLlex.c index e6ddc619a..8180adb80 100644 --- a/util/cpp/LLlex.c +++ b/util/cpp/LLlex.c @@ -203,7 +203,7 @@ go_on: while (c != '\'') { if (c == '\n') { error("newline in character constant"); - LineNumber++; + PushBack(); break; } if (c == '\\') { @@ -299,7 +299,7 @@ string_token(nm, stop_char) while (c != stop_char) { if (c == '\n') { error("newline in %s", nm); - LineNumber++; + PushBack(); break; } if (c == EOI) { diff --git a/util/cpp/domacro.c b/util/cpp/domacro.c index 8b01e53e8..fc57ab333 100644 --- a/util/cpp/domacro.c +++ b/util/cpp/domacro.c @@ -70,7 +70,6 @@ domacro() id = findidf(tk.tk_str); if (!id) { error("%s: unknown control", tk.tk_str); - PushBack(); skipline(); free(tk.tk_str); break; @@ -119,13 +118,11 @@ domacro() case K_PRAGMA: /* "pragma" */ /* ignore for now */ - PushBack(); skipline(); break; default: /* invalid word seen after the '#' */ error("%s: unknown control", id->id_text); - PushBack(); skipline(); } break; @@ -182,27 +179,35 @@ skip_block(to_endif) id = findidf(tk.tk_str); free(tk.tk_str); if (id) switch(id->id_resmac) { + default: + skipline(); + break; case K_IF: case K_IFDEF: case K_IFNDEF: push_if(); + skipline(); continue; case K_ELIF: + if (ifstack[nestlevel]) + warning("#elif after #else/#elif"); if (! to_endif && nestlevel == skiplevel) { nestlevel--; push_if(); - if (ifexpr()) { + if (ifexpr()) { /* implicit skipline() */ NoUnstack--; return; } } + else skipline(); break; case K_ELSE: + if (ifstack[nestlevel]) + warning("#else after #else/#elif"); + skipline(); if (! to_endif) { ++(ifstack[nestlevel]); if (nestlevel == skiplevel) { - PushBack(); - skipline(); NoUnstack--; return; } @@ -210,9 +215,8 @@ skip_block(to_endif) break; case K_ENDIF: assert(nestlevel >= 0); + skipline(); if (nestlevel == skiplevel) { - PushBack(); - skipline(); nestlevel--; NoUnstack--; return; @@ -345,7 +349,6 @@ do_elif() { if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel])) { error("#elif without corresponding #if"); - PushBack(); skipline(); } else { /* restart at this level as if a #if is detected. */ @@ -358,7 +361,6 @@ do_elif() PRIVATE do_else() { - PushBack(); skipline(); if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel])) error("#else without corresponding #if"); @@ -371,7 +373,6 @@ do_else() PRIVATE do_endif() { - PushBack(); skipline(); if (nestlevel <= svnestlevel[nestcount]) error("#endif without corresponding #if");