From e1870047c6046573cbf6d4dec8936c7b4d7a1126 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 29 Mar 2024 14:58:46 +0100 Subject: [PATCH] cppparser: In preprocess mode, add newline when switching files --- dtool/src/cppparser/cppPreprocessor.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index 9c9967bc78..0aa7e69762 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -404,7 +404,13 @@ preprocess_file(const Filename &filename) { } next_space = (token._token != '(' && token._token != '~'); token.output_code(std::cout); - token = get_next_token(); + + CPPToken next_token = get_next_token(); + if (next_token._lloc.file != token._lloc.file) { + // Switched to a new file, reset the line number. + line_number = 0; + } + token = next_token; } std::cout << "\n";