Move more statements into for loop clauses

This commit is contained in:
Rangi
2021-11-19 22:55:20 -05:00
parent c7322258fc
commit cedfd2582a
2 changed files with 10 additions and 17 deletions

View File

@@ -1084,12 +1084,11 @@ static void discardComment(void)
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 @@ static void readLineContinuation(void)
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 @@ static int skipIfBlock(bool toEndc)
if (atLineStart) {
int c;
for (;;) {
for (;; shiftChar()) {
c = peek();
if (!isWhitespace(c))
break;
shiftChar();
}
if (startsIdentifier(c)) {
@@ -2514,7 +2512,7 @@ bool lexer_CaptureRept(struct CaptureBody *capture)
}
/* 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 @@ bool lexer_CaptureRept(struct CaptureBody *capture)
handleCRLF(c);
break;
}
c = nextChar();
}
}
@@ -2571,7 +2568,7 @@ bool lexer_CaptureMacroBody(struct CaptureBody *capture)
}
/* 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 @@ bool lexer_CaptureMacroBody(struct CaptureBody *capture)
handleCRLF(c);
break;
}
c = nextChar();
}
}

View File

@@ -218,17 +218,14 @@ void processWarningFlag(char *flag)
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;
}
}