Avoid use of goto in shiftChar

This commit is contained in:
Rangi42
2025-02-27 14:07:55 -05:00
parent d8192560b0
commit 2cdbb145da

View File

@@ -862,14 +862,14 @@ static void shiftChar() {
lexerState->macroArgScanDistance--; lexerState->macroArgScanDistance--;
restart: for (;;) {
if (!lexerState->expansions.empty()) { if (!lexerState->expansions.empty()) {
// Advance within the current expansion // Advance within the current expansion
if (Expansion &exp = lexerState->expansions.front(); exp.advance()) { if (Expansion &exp = lexerState->expansions.front(); exp.advance()) {
// When advancing would go past an expansion's end, // When advancing would go past an expansion's end,
// move up to its parent and try again to advance // move up to its parent and try again to advance
lexerState->expansions.pop_front(); lexerState->expansions.pop_front();
goto restart; continue;
} }
} else { } else {
// Advance within the file contents // Advance within the file contents
@@ -879,6 +879,8 @@ restart:
lexerState->content.get<BufferedContent>().advance(); lexerState->content.get<BufferedContent>().advance();
} }
} }
return;
}
} }
static int nextChar() { static int nextChar() {
@@ -2114,7 +2116,7 @@ append:
} }
} }
finish: finish: // Can't `break` out of a nested `for`-`switch`
// Trim right whitespace // Trim right whitespace
auto rightPos = std::find_if_not(str.rbegin(), str.rend(), isWhitespace); auto rightPos = std::find_if_not(str.rbegin(), str.rend(), isWhitespace);
str.resize(rightPos.base() - str.begin()); str.resize(rightPos.base() - str.begin());