diff --git a/lib/settings.cpp b/lib/settings.cpp index 784b000dc..c51fac185 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -17,6 +17,7 @@ */ #include "settings.h" +#include "path.h" #include #include @@ -224,7 +225,7 @@ std::string Settings::Suppressions::FileMatcher::addFile(const std::string &name } else { - _files[name][line] = false; + _files[Path::simplifyPath(name.c_str())][line] = false; } return ""; } diff --git a/test/testsettings.cpp b/test/testsettings.cpp index 078324be2..447d7aa52 100644 --- a/test/testsettings.cpp +++ b/test/testsettings.cpp @@ -37,6 +37,7 @@ private: TEST_CASE(suppressionsDosFormat); // Ticket #1836 TEST_CASE(suppressionsFileNameWithColon); // Ticket #1919 - filename includes colon TEST_CASE(suppressionsGlob); + TEST_CASE(suppressionsFileNameWithExtraPath); } void suppressionsBadId1() @@ -99,6 +100,14 @@ private: ASSERT_EQUALS(true, suppressions.isSuppressed("errorid", "abc.cpp", 2)); } } + + void suppressionsFileNameWithExtraPath() + { + // Ticket #2797 + Settings::Suppressions suppressions; + suppressions.addSuppression("errorid", "./a.c", 123); + ASSERT_EQUALS(true, suppressions.isSuppressed("errorid", "a.c", 123)); + } }; REGISTER_TEST(TestSettings)