ref: cedfd2582a646166fe473f33b7c95f5c11701c1c
parent: c7322258fc4cab0c0e68926e8fea107731b02eda
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Fri Nov 19 17:55:20 EST 2021
Move more statements into `for` loop clauses
--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -1084,12 +1084,11 @@
dbgPrint("Discarding comment\n");
lexerState->disableMacroArgs = true;
lexerState->disableInterpolation = true;
- for (;;) {
+ for (;; shiftChar()) {
int c = peek();
if (c == EOF || c == '\r' || c == '\n')
break;
- shiftChar();
}
lexerState->disableMacroArgs = false;
lexerState->disableInterpolation = false;
@@ -1111,13 +1110,13 @@
handleCRLF(c);
if (!lexerState->expansions)
nextLine();
- return;
+ break;
} else if (c == ';') {
discardComment();
} else {
error("Begun line continuation, but encountered character %s\n",
printChar(c));
- return;
+ break;
}
}
}
@@ -2240,11 +2239,10 @@
if (atLineStart) {
int c;
- for (;;) {
+ for (;; shiftChar()) {
c = peek();
if (!isWhitespace(c))
break;
- shiftChar();
}
if (startsIdentifier(c)) {
@@ -2514,7 +2512,7 @@
}
/* Just consume characters until EOL or EOF */
- for (;;) {
+ for (;; c = nextChar()) {
if (c == EOF) {
error("Unterminated REPT/FOR block\n");
goto finish;
@@ -2522,7 +2520,6 @@
handleCRLF(c);
break;
}
- c = nextChar();
}
}
@@ -2571,7 +2568,7 @@
}
/* Just consume characters until EOL or EOF */
- for (;;) {
+ for (;; c = nextChar()) {
if (c == EOF) {
error("Unterminated macro definition\n");
goto finish;
@@ -2579,7 +2576,6 @@
handleCRLF(c);
break;
}
- c = nextChar();
}
}
--- a/src/asm/warning.c
+++ b/src/asm/warning.c
@@ -218,17 +218,14 @@
errx(1, "Cannot make meta warning \"%s\" into an error",
flag);
- uint8_t const *ptr = metaWarningCommands[id - META_WARNINGS_START];
-
- for (;;) {
- if (*ptr == META_WARNING_DONE)
- return;
-
+ for (uint8_t const *ptr = metaWarningCommands[id - META_WARNINGS_START];
+ *ptr != META_WARNING_DONE; ptr++) {
/* Warning flag, set without override */
if (warningStates[*ptr] == WARNING_DEFAULT)
warningStates[*ptr] = WARNING_ENABLED;
- ptr++;
}
+
+ return;
}
}