@@ -382,10 +382,10 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
382382 bool def = false ;
383383 bool maxconfigs = false ;
384384 bool debug = false ;
385+ bool inputAsFilter = false ; // set by: --file-filter=+
385386
386387 ImportProject::Type projectType = ImportProject::Type::NONE;
387388 ImportProject project;
388- bool projectSettings = false ;
389389 std::string vsConfig;
390390
391391 std::string platform;
@@ -769,6 +769,8 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
769769 mLogger .printError (" Failed: --file-filter=-" );
770770 return Result::Fail;
771771 }
772+ } else if (std::strcmp (filter, " +" ) == 0 ) {
773+ inputAsFilter = true ;
772774 } else {
773775 mSettings .fileFilters .emplace_back (filter);
774776 }
@@ -1133,18 +1135,16 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
11331135 }
11341136 }
11351137
1136- // --project, --project-settings
1137- else if (std::strncmp (argv[i], " --project=" , 10 ) == 0 || std::strncmp (argv[i], " --project-settings= " , 19 ) == 0 ) {
1138+ // --project
1139+ else if (std::strncmp (argv[i], " --project=" , 10 ) == 0 ) {
11381140 if (projectType != ImportProject::Type::NONE)
11391141 {
11401142 mLogger .printError (" multiple --project options are not supported." );
11411143 return Result::Fail;
11421144 }
11431145
1144- projectSettings = (std::strncmp (argv[i], " --project-settings=" , 19 ) == 0 );
1145-
11461146 mSettings .checkAllConfigurations = false ; // Can be overridden with --max-configs or --force
1147- std::string projectFile = std::strchr ( argv[i], ' = ' ) + 1 ;
1147+ std::string projectFile = argv[i]+ 10 ;
11481148 projectType = project.import (projectFile, &mSettings , &mSuppressions , isCppcheckPremium ());
11491149 if (projectType == ImportProject::Type::CPPCHECK_GUI) {
11501150 for (const std::string &lib : project.guiProject .libraries )
@@ -1585,7 +1585,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
15851585 // mLogger.printMessage("whole program analysis requires --cppcheck-build-dir to be active with -j.");
15861586 }
15871587
1588- if (projectSettings ) {
1588+ if (inputAsFilter ) {
15891589 mSettings .fileFilters .insert (mSettings .fileFilters .end (), mPathNames .cbegin (), mPathNames .cend ());
15901590 mPathNames .clear ();
15911591 }
@@ -1785,10 +1785,12 @@ void CmdLineParser::printHelp() const
17851785 " --exitcode-suppressions=<file>\n "
17861786 " Used when certain messages should be displayed but\n "
17871787 " should not cause a non-zero exitcode.\n "
1788- " --file-filter=<str> Analyze only those files matching the given filter str\n "
1789- " Can be used multiple times\n "
1788+ " --file-filter=<str> Analyze only those files matching the given filter str.\n "
1789+ " Can be used multiple times. When str is '-', the file\n "
1790+ " filter will be read from standard input. When str is '+',\n "
1791+ " all path arguments are treated as file filters.\n "
17901792 " Example: --file-filter=*bar.cpp analyzes only files\n "
1791- " that end with bar.cpp.\n "
1793+ " that end with bar.cpp.\n "
17921794 " --file-list=<file> Specify the files to check in a text file. Add one\n "
17931795 " filename per line. When file is '-,' the file list will\n "
17941796 " be read from standard input.\n "
@@ -1926,16 +1928,6 @@ void CmdLineParser::printHelp() const
19261928 " or Visual Studio Project (*.vcxproj) you can limit\n "
19271929 " the configuration cppcheck should check.\n "
19281930 " For example: '--project-configuration=Release|Win32'\n "
1929- " --project-settings=<file>\n "
1930- " IDE option: Import settings from project file. Preprocessor\n "
1931- " settings, suppressions, coding standards, etc. are imported.\n "
1932- " Unlike --project the files to analyse is not imported with this\n "
1933- " option.\n "
1934- " These two commands are effectively the same:\n "
1935- " cppcheck --project=foo --file-filter=src/test.c\n "
1936- " cppcheck --project-settings=foo src/test.c\n "
1937- " Both commands will load the project foo and then analyse only the\n "
1938- " file src/test.c\n "
19391931 " -q, --quiet Do not show progress reports.\n "
19401932 " Note that this option is not mutually exclusive with --verbose.\n "
19411933 " -rp=<paths>, --relative-paths=<paths>\n "
0 commit comments