Skip to content

Commit ecf689f

Browse files
Update simplecpp.cpp
1 parent 435a74c commit ecf689f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

simplecpp.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3119,6 +3119,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31193119
FileDataCache cache;
31203120

31213121
std::list<const Token *> filelist;
3122+
std::set<const Token *> processed;
31223123

31233124
// -include files
31243125
for (std::list<std::string>::const_iterator it = dui.includes.begin(); it != dui.includes.end(); ++it) {
@@ -3154,6 +3155,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31543155
for (const Token *rawtok = rawtokens.cfront(); rawtok || !filelist.empty(); rawtok = rawtok ? rawtok->next : nullptr) {
31553156
if (rawtok == nullptr) {
31563157
rawtok = filelist.back();
3158+
processed.emplace(rawtok);
31573159
filelist.pop_back();
31583160
}
31593161

@@ -3180,7 +3182,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31803182
if (dui.removeComments)
31813183
filedata->tokens.removeComments();
31823184

3183-
if (filedata->tokens.front())
3185+
if (filedata->tokens.front() && processed.find(filedata->tokens.front()) == processed.end())
31843186
filelist.push_back(filedata->tokens.front());
31853187
}
31863188

0 commit comments

Comments
 (0)