diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index cda562b2995..8e270736dae 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -825,8 +825,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a } if (!path.empty()) { - path = Path::removeQuotationMarks(std::move(path)); - path = Path::simplifyPath(std::move(path)); mIgnoredPaths.emplace_back(std::move(path)); } } @@ -1589,6 +1587,9 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a for (auto& path : mIgnoredPaths) { + path = Path::removeQuotationMarks(std::move(path)); + path = Path::simplifyPath(std::move(path)); + bool isdir = false; if (!Path::exists(path, &isdir) && mSettings.debugignore) std::cout << "path to ignore does not exist: " << path << std::endl; diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index bd87296927c..efadfb1d2bf 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -454,6 +454,7 @@ class TestCmdlineParser : public TestFixture { TEST_CASE(ignorefilepaths6); TEST_CASE(ignorefilepaths7); TEST_CASE(ignorefilepaths8); + TEST_CASE(ignorefilepaths9); TEST_CASE(nonexistentpath); @@ -3114,6 +3115,17 @@ class TestCmdlineParser : public TestFixture { ASSERT_EQUALS("cppcheck: error: could not find or open any of the paths given.\ncppcheck: Maybe all paths were ignored?\n", logger->str()); } + void ignorefilepaths9() { + REDIRECT; + const char * const argv[] = {"cppcheck", "-isrc\\", "src\\file.cpp"}; + ASSERT(!fillSettingsFromArgs(argv)); + ASSERT_EQUALS(1, parser->getIgnoredPaths().size()); + ASSERT_EQUALS("src/", parser->getIgnoredPaths()[0]); + ASSERT_EQUALS(1, parser->getPathNames().size()); + ASSERT_EQUALS("src/file.cpp", parser->getPathNames()[0]); + ASSERT_EQUALS("cppcheck: error: could not find or open any of the paths given.\ncppcheck: Maybe all paths were ignored?\n", logger->str()); + } + void nonexistentpath() { REDIRECT; const char * const argv[] = {"cppcheck", "file.cpp"};