@@ -209,11 +209,13 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[])
209209 std::list<FileSettings> fileSettings;
210210 if (!mSettings .fileFilters .empty ()) {
211211 // filter only for the selected filenames from all project files
212+ PathMatch filtermatcher (mSettings .fileFilters , Path::getCurrentPath ());
212213 std::copy_if (fileSettingsRef.cbegin (), fileSettingsRef.cend (), std::back_inserter (fileSettings), [&](const FileSettings &fs) {
213- return matchglobs ( mSettings . fileFilters , fs.filename ());
214+ return filtermatcher. match ( fs.filename ());
214215 });
215216 if (fileSettings.empty ()) {
216- mLogger .printError (" could not find any files matching the filter." );
217+ for (const std::string& f: mSettings .fileFilters )
218+ mLogger .printError (" could not find any files matching the filter:" + f);
217219 return false ;
218220 }
219221 }
@@ -242,16 +244,9 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[])
242244
243245 if (!pathnamesRef.empty ()) {
244246 std::list<FileWithDetails> filesResolved;
245- // TODO: this needs to be inlined into PathMatch as it depends on the underlying filesystem
246- #if defined(_WIN32)
247- // For Windows we want case-insensitive path matching
248- const bool caseSensitive = false ;
249- #else
250- const bool caseSensitive = true ;
251- #endif
252247 // Execute recursiveAddFiles() to each given file parameter
253248 // TODO: verbose log which files were ignored?
254- const PathMatch matcher (ignored, caseSensitive );
249+ const PathMatch matcher (ignored, Path::getCurrentPath () );
255250 for (const std::string &pathname : pathnamesRef) {
256251 const std::string err = FileLister::recursiveAddFiles (filesResolved, Path::toNativeSeparators (pathname), mSettings .library .markupExtensions (), matcher, mSettings .debugignore );
257252 if (!err.empty ()) {
@@ -285,7 +280,8 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[])
285280 if (!mSettings .fileFilters .empty ()) {
286281 files = filterFiles (mSettings .fileFilters , filesResolved);
287282 if (files.empty ()) {
288- mLogger .printError (" could not find any files matching the filter." );
283+ for (const std::string& f: mSettings .fileFilters )
284+ mLogger .printError (" could not find any files matching the filter:" + f);
289285 return false ;
290286 }
291287 }
@@ -1130,7 +1126,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
11301126
11311127 mSettings .checkAllConfigurations = false ; // Can be overridden with --max-configs or --force
11321128 std::string projectFile = argv[i]+10 ;
1133- projectType = project.import (projectFile, &mSettings , &mSuppressions );
1129+ projectType = project.import (projectFile, &mSettings , &mSuppressions , isCppcheckPremium () );
11341130 if (projectType == ImportProject::Type::CPPCHECK_GUI) {
11351131 for (const std::string &lib : project.guiProject .libraries )
11361132 mSettings .libraries .emplace_back (lib);
@@ -1622,19 +1618,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
16221618 for (auto & path : mIgnoredPaths )
16231619 {
16241620 path = Path::removeQuotationMarks (std::move (path));
1625- path = Path::simplifyPath (std::move (path));
1626-
1627- bool isdir = false ;
1628- if (!Path::exists (path, &isdir) && mSettings .debugignore ) {
1629- // FIXME: this is misleading because we match from the end of the path so it does not require to exist
1630- // std::cout << "path to ignore does not exist: " << path << std::endl;
1631- }
1632- // TODO: this only works when it exists
1633- if (isdir) {
1634- // If directory name doesn't end with / or \, add it
1635- if (!endsWith (path, ' /' ))
1636- path += ' /' ;
1637- }
1621+ path = Path::fromNativeSeparators (std::move (path));
16381622 }
16391623
16401624 if (!project.guiProject .pathNames .empty ())
@@ -1792,10 +1776,9 @@ void CmdLineParser::printHelp() const
17921776 " this is not needed.\n "
17931777 " --include=<file>\n "
17941778 " Force inclusion of a file before the checked file.\n "
1795- " -i <dir or file> Give a source file or source file directory to exclude\n "
1796- " from the check. This applies only to source files so\n "
1797- " header files included by source files are not matched.\n "
1798- " Directory name is matched to all parts of the path.\n "
1779+ " -i <str> Exclude source files or directories matching str from\n "
1780+ " the check. This applies only to source files so header\n "
1781+ " files included by source files are not matched.\n "
17991782 " --inconclusive Allow that Cppcheck reports even though the analysis is\n "
18001783 " inconclusive.\n "
18011784 " There are false positives with this option. Each result\n "
@@ -2160,13 +2143,9 @@ bool CmdLineParser::loadCppcheckCfg()
21602143std::list<FileWithDetails> CmdLineParser::filterFiles (const std::vector<std::string>& fileFilters,
21612144 const std::list<FileWithDetails>& filesResolved) {
21622145 std::list<FileWithDetails> files;
2163- #ifdef _WIN32
2164- constexpr bool caseInsensitive = true ;
2165- #else
2166- constexpr bool caseInsensitive = false ;
2167- #endif
2146+ PathMatch filtermatcher (fileFilters, Path::getCurrentPath ());
21682147 std::copy_if (filesResolved.cbegin (), filesResolved.cend (), std::inserter (files, files.end ()), [&](const FileWithDetails& entry) {
2169- return matchglobs (fileFilters, entry.path (), caseInsensitive) || matchglobs (fileFilters, entry. spath (), caseInsensitive );
2148+ return filtermatcher. match ( entry.path ());
21702149 });
21712150 return files;
21722151}
0 commit comments