removed some useless PushBack's, and added warnings

This commit is contained in:
ceriel 1989-06-27 11:43:26 +00:00
parent 27d7d5ed68
commit f781103cb4
2 changed files with 14 additions and 13 deletions

View file

@ -203,7 +203,7 @@ go_on:
while (c != '\'') { while (c != '\'') {
if (c == '\n') { if (c == '\n') {
error("newline in character constant"); error("newline in character constant");
LineNumber++; PushBack();
break; break;
} }
if (c == '\\') { if (c == '\\') {
@ -299,7 +299,7 @@ string_token(nm, stop_char)
while (c != stop_char) { while (c != stop_char) {
if (c == '\n') { if (c == '\n') {
error("newline in %s", nm); error("newline in %s", nm);
LineNumber++; PushBack();
break; break;
} }
if (c == EOI) { if (c == EOI) {

View file

@ -70,7 +70,6 @@ domacro()
id = findidf(tk.tk_str); id = findidf(tk.tk_str);
if (!id) { if (!id) {
error("%s: unknown control", tk.tk_str); error("%s: unknown control", tk.tk_str);
PushBack();
skipline(); skipline();
free(tk.tk_str); free(tk.tk_str);
break; break;
@ -119,13 +118,11 @@ domacro()
case K_PRAGMA: /* "pragma" */ case K_PRAGMA: /* "pragma" */
/* ignore for now /* ignore for now
*/ */
PushBack();
skipline(); skipline();
break; break;
default: default:
/* invalid word seen after the '#' */ /* invalid word seen after the '#' */
error("%s: unknown control", id->id_text); error("%s: unknown control", id->id_text);
PushBack();
skipline(); skipline();
} }
break; break;
@ -182,27 +179,35 @@ skip_block(to_endif)
id = findidf(tk.tk_str); id = findidf(tk.tk_str);
free(tk.tk_str); free(tk.tk_str);
if (id) switch(id->id_resmac) { if (id) switch(id->id_resmac) {
default:
skipline();
break;
case K_IF: case K_IF:
case K_IFDEF: case K_IFDEF:
case K_IFNDEF: case K_IFNDEF:
push_if(); push_if();
skipline();
continue; continue;
case K_ELIF: case K_ELIF:
if (ifstack[nestlevel])
warning("#elif after #else/#elif");
if (! to_endif && nestlevel == skiplevel) { if (! to_endif && nestlevel == skiplevel) {
nestlevel--; nestlevel--;
push_if(); push_if();
if (ifexpr()) { if (ifexpr()) { /* implicit skipline() */
NoUnstack--; NoUnstack--;
return; return;
} }
} }
else skipline();
break; break;
case K_ELSE: case K_ELSE:
if (ifstack[nestlevel])
warning("#else after #else/#elif");
skipline();
if (! to_endif) { if (! to_endif) {
++(ifstack[nestlevel]); ++(ifstack[nestlevel]);
if (nestlevel == skiplevel) { if (nestlevel == skiplevel) {
PushBack();
skipline();
NoUnstack--; NoUnstack--;
return; return;
} }
@ -210,9 +215,8 @@ skip_block(to_endif)
break; break;
case K_ENDIF: case K_ENDIF:
assert(nestlevel >= 0); assert(nestlevel >= 0);
skipline();
if (nestlevel == skiplevel) { if (nestlevel == skiplevel) {
PushBack();
skipline();
nestlevel--; nestlevel--;
NoUnstack--; NoUnstack--;
return; return;
@ -345,7 +349,6 @@ do_elif()
{ {
if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel])) { if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel])) {
error("#elif without corresponding #if"); error("#elif without corresponding #if");
PushBack();
skipline(); skipline();
} }
else { /* restart at this level as if a #if is detected. */ else { /* restart at this level as if a #if is detected. */
@ -358,7 +361,6 @@ do_elif()
PRIVATE PRIVATE
do_else() do_else()
{ {
PushBack();
skipline(); skipline();
if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel])) if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel]))
error("#else without corresponding #if"); error("#else without corresponding #if");
@ -371,7 +373,6 @@ do_else()
PRIVATE PRIVATE
do_endif() do_endif()
{ {
PushBack();
skipline(); skipline();
if (nestlevel <= svnestlevel[nestcount]) if (nestlevel <= svnestlevel[nestcount])
error("#endif without corresponding #if"); error("#endif without corresponding #if");