From fff8aa8590da18808099f72af19e5e35472f4446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 2 Oct 2016 13:32:39 +0200 Subject: [PATCH] dmake: pathmatch was moved from cli to lib --- Makefile | 4 ++-- lib/pathmatch.cpp | 6 ++---- lib/pathmatch.h | 1 + tools/dmake.cpp | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 115f41ca7..9b3739918 100644 --- a/Makefile +++ b/Makefile @@ -252,8 +252,8 @@ cppcheck: $(LIBOBJ) $(CLIOBJ) $(EXTOBJ) all: cppcheck testrunner -testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o lib/pathmatch.o - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cppcheckexecutor.o cli/cmdlineparser.o cli/filelister.o lib/pathmatch.o $(EXTOBJ) $(LIBS) $(LDFLAGS) $(RDYNAMIC) +testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cppcheckexecutor.o cli/cmdlineparser.o cli/filelister.o $(EXTOBJ) $(LIBS) $(LDFLAGS) $(RDYNAMIC) test: all ./testrunner diff --git a/lib/pathmatch.cpp b/lib/pathmatch.cpp index c981e97ab..0343acf11 100644 --- a/lib/pathmatch.cpp +++ b/lib/pathmatch.cpp @@ -27,6 +27,7 @@ PathMatch::PathMatch(const std::vector &excludedPaths, bool caseSen if (!_caseSensitive) for (std::vector::iterator i = _excludedPaths.begin(); i != _excludedPaths.end(); ++i) std::transform(i->begin(), i->end(), i->begin(), ::tolower); + _workingDirectory.push_back(Path::getCurrentPath()); } bool PathMatch::Match(const std::string &path) const @@ -34,11 +35,8 @@ bool PathMatch::Match(const std::string &path) const if (path.empty()) return false; - std::vector workingDirectory; - workingDirectory.push_back(Path::getCurrentPath()); - for (std::vector::const_iterator i = _excludedPaths.begin(); i != _excludedPaths.end(); ++i) { - const std::string excludedPath((!Path::isAbsolute(path) && Path::isAbsolute(*i)) ? Path::getRelativePath(*i, workingDirectory) : *i); + const std::string excludedPath((!Path::isAbsolute(path) && Path::isAbsolute(*i)) ? Path::getRelativePath(*i, _workingDirectory) : *i); std::string findpath = Path::fromNativeSeparators(path); if (!_caseSensitive) diff --git a/lib/pathmatch.h b/lib/pathmatch.h index 6b5607c52..0e9201a38 100644 --- a/lib/pathmatch.h +++ b/lib/pathmatch.h @@ -58,6 +58,7 @@ protected: private: std::vector _excludedPaths; bool _caseSensitive; + std::vector _workingDirectory; }; /// @} diff --git a/tools/dmake.cpp b/tools/dmake.cpp index f9073f5a1..8b57e2c25 100644 --- a/tools/dmake.cpp +++ b/tools/dmake.cpp @@ -369,8 +369,8 @@ int main(int argc, char **argv) fout << "cppcheck: $(LIBOBJ) $(CLIOBJ) $(EXTOBJ)\n"; fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(EXTOBJ) $(LIBS) $(LDFLAGS) $(RDYNAMIC)\n\n"; fout << "all:\tcppcheck testrunner\n\n"; - fout << "testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o lib/pathmatch.o\n"; - fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cppcheckexecutor.o cli/cmdlineparser.o cli/filelister.o lib/pathmatch.o $(EXTOBJ) $(LIBS) $(LDFLAGS) $(RDYNAMIC)\n\n"; + fout << "testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o\n"; + fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cppcheckexecutor.o cli/cmdlineparser.o cli/filelister.o $(EXTOBJ) $(LIBS) $(LDFLAGS) $(RDYNAMIC)\n\n"; fout << "test:\tall\n"; fout << "\t./testrunner\n\n"; fout << "check:\tall\n";