Skip to content

Commit 9935591

Browse files
committed
Fix false matches in getFileIdPath
1 parent 8b06465 commit 9935591

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

simplecpp.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3278,6 +3278,13 @@ static std::string getFileIdPath(const std::map<std::string, simplecpp::TokenLis
32783278
if (!match.empty()) {
32793279
return match;
32803280
}
3281+
// if the file exists but hasn't been loaded yet then we need to stop searching here or we could get a false match
3282+
std::ifstream f;
3283+
openHeader(f, relativeOrAbsoluteFilename);
3284+
if (f.is_open()) {
3285+
f.close();
3286+
return "";
3287+
}
32813288
} else if (filedata.find(header) != filedata.end()) {
32823289
return header;// system header that its file is already in the filedata - return that as is
32833290
}

0 commit comments

Comments
 (0)