Skip to content

Commit a8adb1a

Browse files
committed
Improved handling of '..' in realFilename() in Linux. This fixes issue cppcheck-opensource#68
1 parent 9022cf8 commit a8adb1a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

simplecpp.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ static bool sameline(const simplecpp::Token *tok1, const simplecpp::Token *tok2)
112112
return tok1 && tok2 && tok1->location.sameline(tok2->location);
113113
}
114114

115-
116115
static bool isAlternativeBinaryOp(const simplecpp::Token *tok, const std::string &alt)
117116
{
118117
return (tok->name &&
@@ -1661,6 +1660,10 @@ namespace simplecpp {
16611660
std::ostringstream ostr;
16621661
std::string::size_type sep = 0;
16631662
while ((sep = f.find_first_of("\\/", sep + 1U)) != std::string::npos) {
1663+
if (sep >= 2 && f.compare(sep-2,2,"..",0,2) == 0) {
1664+
ostr << "../";
1665+
continue;
1666+
}
16641667
buf[sep] = 0;
16651668
if (!realFileName(buf,ostr))
16661669
return f;

0 commit comments

Comments
 (0)