Avoid use of goto in nextLine

This commit is contained in:
Rangi42
2025-02-27 14:28:17 -05:00
parent 2cdbb145da
commit 00d0ae840d

View File

@@ -34,9 +34,10 @@ static char const *delim = " \f\n\r\t\v"; // Whitespace according to the C and P
static int static int
nextLine(std::vector<char> &lineBuf, uint32_t &lineNo, FileStackNode const &where, FILE *file) { nextLine(std::vector<char> &lineBuf, uint32_t &lineNo, FileStackNode const &where, FILE *file) {
retry: int firstChar;
for (;;) {
++lineNo; ++lineNo;
int firstChar = getc(file); firstChar = getc(file);
lineBuf.clear(); lineBuf.clear();
switch (firstChar) { switch (firstChar) {
@@ -55,7 +56,9 @@ retry:
} }
[[fallthrough]]; [[fallthrough]];
case '\n': case '\n':
goto retry; continue;
}
break;
} }
for (;;) { for (;;) {