preproc: Parse cpp linemarkers

The line numbers in preproc's errors involving strings or INCBINs were
incorrect before this change because all the lines from '#include'd
files incremented the line number that would be reported.
This commit is contained in:
Martin Griffin
2026-05-13 05:55:12 +01:00
parent a3c551fe21
commit e38dfaa92c
4 changed files with 95 additions and 19 deletions
+2 -1
View File
@@ -204,8 +204,9 @@ void StringParser::RaiseError(const char* format, ...)
std::va_list args;
va_start(args, format);
std::vsnprintf(buffer, bufferSize, format, args);
int n = std::vsnprintf(buffer, bufferSize, format, args);
va_end(args);
std::snprintf(buffer + n, bufferSize - n, " before '%.10s'", &m_buffer[m_pos]);
throw std::runtime_error(buffer);
}