rgbasm: Save some horizontal space in main.c.

This commit is contained in:
Anthony J. Bentley
2015-01-22 20:33:07 -07:00
parent 91241b44da
commit cd2af0204e

View File

@@ -323,6 +323,7 @@ main(int argc, char *argv[])
nErrors = 0; nErrors = 0;
sym_PrepPass1(); sym_PrepPass1();
fstk_Init(tzMainfile); fstk_Init(tzMainfile);
if (CurrentOptions.verbose) { if (CurrentOptions.verbose) {
printf("Pass 1...\n"); printf("Pass 1...\n");
} }
@@ -330,8 +331,14 @@ main(int argc, char *argv[])
yy_set_state(LEX_STATE_NORMAL); yy_set_state(LEX_STATE_NORMAL);
opt_SetCurrentOptions(&DefaultOptions); opt_SetCurrentOptions(&DefaultOptions);
if (yyparse() == 0 && nErrors == 0) { if (yyparse() != 0 || nErrors != 0) {
if (nIFDepth == 0) { errx(1, "Assembly aborted in pass 1 (%ld errors)!", nErrors);
}
if (nIFDepth != 0) {
errx(1, "Unterminated IF construct (%ld levels)!", nIFDepth);
}
nTotalLines = 0; nTotalLines = 0;
nLineNo = 1; nLineNo = 1;
nIFDepth = 0; nIFDepth = 0;
@@ -348,40 +355,24 @@ main(int argc, char *argv[])
printf("Pass 2...\n"); printf("Pass 2...\n");
} }
if (yyparse() == 0 && nErrors == 0) { if (yyparse() != 0 || nErrors != 0) {
errx(1, "Assembly aborted in pass 2 (%ld errors)!", nErrors);
}
double timespent; double timespent;
nEndClock = clock(); nEndClock = clock();
timespent = timespent = ((double)(nEndClock - nStartClock))
((double) (nEndClock - nStartClock))
/ (double)CLOCKS_PER_SEC; / (double)CLOCKS_PER_SEC;
if (CurrentOptions.verbose) { if (CurrentOptions.verbose) {
printf printf("Success! %ld lines in %d.%02d seconds ", nTotalLines,
("Success! %ld lines in %d.%02d seconds ", (int) timespent, ((int) (timespent * 100.0)) % 100);
nTotalLines, (int) timespent,
((int) (timespent * 100.0)) % 100);
if (timespent == 0) if (timespent == 0)
printf printf("(INFINITY lines/minute)\n");
("(INFINITY lines/minute)\n");
else else
printf("(%d lines/minute)\n", printf("(%d lines/minute)\n",
(int) (60 / timespent * (int) (60 / timespent * nTotalLines));
nTotalLines));
} }
out_WriteObject(); out_WriteObject();
} else {
printf
("Assembly aborted in pass 2 (%ld errors)!\n",
nErrors);
exit(5);
}
} else {
errx(1, "Unterminated IF construct (%ld levels)!",
nIFDepth);
}
} else {
errx(1, "Assembly aborted in pass 1 (%ld errors)!",
nErrors);
}
return 0; return 0;
} }