mirror of
https://github.com/gbdev/rgbds.git
synced 2026-07-02 05:58:04 +00:00
Fix off-by-one error with INCLUDEd linker script line numbers
This commit is contained in:
+5
-4
@@ -52,11 +52,10 @@ void lexer_IncludeFile(std::string &&path) {
|
||||
scriptError(
|
||||
"Failed to open included linker script \"%s\": %s", badPath.c_str(), strerror(errno)
|
||||
);
|
||||
// `.pop_back()` cannot invalidate an unpopped reference, so `prevContext`
|
||||
// is still valid even if `.open()` failed.
|
||||
++prevContext.lineNo;
|
||||
}
|
||||
|
||||
// `.pop_back()` cannot invalidate an unpopped reference, so `prevContext`
|
||||
// is still valid even if `.open()` failed.
|
||||
++prevContext.lineNo;
|
||||
}
|
||||
|
||||
void lexer_IncLineNo() {
|
||||
@@ -74,6 +73,8 @@ static yy::parser::symbol_type yywrap() {
|
||||
return yy::parser::make_newline();
|
||||
}
|
||||
lexerStack.pop_back();
|
||||
// Increment the line number *after* an INCLUDE has finished.
|
||||
++lexerStack.back().lineNo;
|
||||
return yylex();
|
||||
}
|
||||
if (!atEof) {
|
||||
|
||||
+2
-1
@@ -52,7 +52,8 @@ lines:
|
||||
|
||||
line:
|
||||
INCLUDE string newline {
|
||||
lexer_IncludeFile(std::move($2)); // Note: this additionally increments the line number!
|
||||
// This does *not* increment the line number until the included content has finished parsing!
|
||||
lexer_IncludeFile(std::move($2));
|
||||
}
|
||||
| directive newline {
|
||||
lexer_IncLineNo();
|
||||
|
||||
Reference in New Issue
Block a user