From ecf689f22e9d05283bb1e7975d03fc5cde7e47fa Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 11 Aug 2025 14:38:57 +0200 Subject: [PATCH] Update simplecpp.cpp --- simplecpp.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/simplecpp.cpp b/simplecpp.cpp index addac46f..0f233dac 100755 --- a/simplecpp.cpp +++ b/simplecpp.cpp @@ -3119,6 +3119,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens, FileDataCache cache; std::list filelist; + std::set processed; // -include files for (std::list::const_iterator it = dui.includes.begin(); it != dui.includes.end(); ++it) { @@ -3154,6 +3155,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens, for (const Token *rawtok = rawtokens.cfront(); rawtok || !filelist.empty(); rawtok = rawtok ? rawtok->next : nullptr) { if (rawtok == nullptr) { rawtok = filelist.back(); + processed.emplace(rawtok); filelist.pop_back(); } @@ -3180,7 +3182,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens, if (dui.removeComments) filedata->tokens.removeComments(); - if (filedata->tokens.front()) + if (filedata->tokens.front() && processed.find(filedata->tokens.front()) == processed.end()) filelist.push_back(filedata->tokens.front()); }