diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 578668e73..fdd6a4cc3 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -64,7 +64,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c // Execute recursiveAddFiles() to each given file parameter std::vector::const_iterator iter; for (iter = pathnames.begin(); iter != pathnames.end(); ++iter) - getFileLister()->recursiveAddFiles(filenames, iter->c_str(), true); + getFileLister()->recursiveAddFiles(filenames, iter->c_str()); for (iter = filenames.begin(); iter != filenames.end(); ++iter) cppcheck->addFile(*iter); diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 402c37a65..2784ec6c4 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -53,7 +53,7 @@ void CppCheck::settings(const Settings ¤tSettings) void CppCheck::addFile(const std::string &path) { - getFileLister()->recursiveAddFiles(_filenames, path.c_str(), true); + getFileLister()->recursiveAddFiles(_filenames, path.c_str()); } void CppCheck::addFile(const std::string &path, const std::string &content) diff --git a/lib/filelister.h b/lib/filelister.h index 86924b13f..7a09b1662 100644 --- a/lib/filelister.h +++ b/lib/filelister.h @@ -45,10 +45,9 @@ public: * (*.c;*.cpp;*.cxx;*.c++;*.cc;*.txx) are added. * @param filenames output vector that filenames are written to * @param path root path - * @param recursive Should files be added recursively or not? */ virtual void recursiveAddFiles(std::vector &filenames, - const std::string &path, bool recursive) = 0; + const std::string &path) = 0; /** * @brief Compare filenames to see if they are the same. diff --git a/lib/filelister_unix.cpp b/lib/filelister_unix.cpp index a2cb5afe4..a8d725cc9 100644 --- a/lib/filelister_unix.cpp +++ b/lib/filelister_unix.cpp @@ -35,7 +35,7 @@ ////// This code is POSIX-style systems /////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -void FileListerUnix::recursiveAddFiles(std::vector &filenames, const std::string &path, bool recursive) +void FileListerUnix::recursiveAddFiles(std::vector &filenames, const std::string &path) { std::ostringstream oss; oss << path; @@ -46,22 +46,20 @@ void FileListerUnix::recursiveAddFiles(std::vector &filenames, cons glob(oss.str().c_str(), GLOB_MARK, 0, &glob_results); for (unsigned int i = 0; i < glob_results.gl_pathc; i++) { - std::string filename = glob_results.gl_pathv[i]; + const std::string filename = glob_results.gl_pathv[i]; if (filename == "." || filename == ".." || filename.length() == 0) continue; if (filename[filename.length()-1] != '/') { // File - - // If recursive is not used, accept all files given by user - if (!recursive || FileLister::acceptFile(filename)) + if (FileLister::acceptFile(filename)) filenames.push_back(filename); } - else if (recursive) + else { // Directory - getFileLister()->recursiveAddFiles(filenames, filename, recursive); + getFileLister()->recursiveAddFiles(filenames, filename); } } globfree(&glob_results); diff --git a/lib/filelister_unix.h b/lib/filelister_unix.h index 3550d9f80..73df8e5f6 100644 --- a/lib/filelister_unix.h +++ b/lib/filelister_unix.h @@ -30,7 +30,7 @@ class FileListerUnix : public FileLister { public: - virtual void recursiveAddFiles(std::vector &filenames, const std::string &path, bool recursive); + virtual void recursiveAddFiles(std::vector &filenames, const std::string &path); virtual bool sameFileName(const std::string &fname1, const std::string &fname2); // virtual static bool acceptFile(const std::string &filename); private: diff --git a/lib/filelister_win32.cpp b/lib/filelister_win32.cpp index e18620069..9e07e7fd9 100644 --- a/lib/filelister_win32.cpp +++ b/lib/filelister_win32.cpp @@ -100,7 +100,7 @@ static HANDLE MyFindFirstFile(std::string path, LPWIN32_FIND_DATA findData) #endif // defined(UNICODE) -void FileListerWin32::recursiveAddFiles(std::vector &filenames, const std::string &path, bool recursive) +void FileListerWin32::recursiveAddFiles(std::vector &filenames, const std::string &path) { // oss is the search string passed into FindFirst and FindNext. // bdir is the base directory which is used to form pathnames. diff --git a/lib/filelister_win32.h b/lib/filelister_win32.h index 84c4964f1..9f0cb1264 100644 --- a/lib/filelister_win32.h +++ b/lib/filelister_win32.h @@ -30,7 +30,7 @@ class FileListerWin32 : public FileLister { public: - virtual void recursiveAddFiles(std::vector &filenames, const std::string &path, bool recursive); + virtual void recursiveAddFiles(std::vector &filenames, const std::string &path); virtual bool sameFileName(const std::string &fname1, const std::string &fname2); private: diff --git a/tools/dmake.cpp b/tools/dmake.cpp index 1ee466e05..d505bb411 100644 --- a/tools/dmake.cpp +++ b/tools/dmake.cpp @@ -87,7 +87,7 @@ static void compilefiles(std::ostream &fout, const std::vector &fil static void getCppFiles(std::vector &files, const std::string &path) { - getFileLister()->recursiveAddFiles(files, path, true); + getFileLister()->recursiveAddFiles(files, path); // only get *.cpp files.. for (std::vector::iterator it = files.begin(); it != files.end();) {