mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 18:52:07 +00:00
Fix incorrect line numbers with some IF blocks
If a line ended with a string's closing quote, or a newline escape, then
skipping over that line via IF/ELIF/ELSE would fail to count that line,
offsetting the rest of the file.
I have no idea why but for some reason 9829be1 changed *specifically*
`if_skip_to_else` to have incorrect behavior on string endings. The incorrect
behavior on newline escapes seems to have been here since the beginning.
Also added a test to check for both of those behaviors in both functions.
Honestly, it baffles me that nobody ever noticed. I didn't until I started
working on #395.
This commit is contained in:
@@ -354,20 +354,14 @@ static void if_skip_to_else(void)
|
||||
src++;
|
||||
}
|
||||
} else {
|
||||
switch (*src) {
|
||||
case '\\':
|
||||
src += 2;
|
||||
break;
|
||||
|
||||
case '\"':
|
||||
src += 2;
|
||||
if (*src == '\"') {
|
||||
inString = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
src++;
|
||||
break;
|
||||
} else if (*src == '\\') {
|
||||
/* Escaped quotes don't end the string */
|
||||
if (*++src != '\"')
|
||||
src--;
|
||||
}
|
||||
src++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,21 +399,14 @@ static void if_skip_to_endc(void)
|
||||
src++;
|
||||
}
|
||||
} else {
|
||||
switch (*src) {
|
||||
|
||||
case '\\':
|
||||
src += 2;
|
||||
break;
|
||||
|
||||
case '\"':
|
||||
src++;
|
||||
if (*src == '\"') {
|
||||
inString = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
src++;
|
||||
break;
|
||||
} else if (*src == '\\') {
|
||||
/* Escaped quotes don't end the string */
|
||||
if (*++src != '\"')
|
||||
src--;
|
||||
}
|
||||
src++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user