@@ -606,9 +606,9 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
606606 mLogger .printError (" no path has been specified for --cppcheck-build-dir" );
607607 return Result::Fail;
608608 }
609+ if (endsWith (path, ' /' ))
610+ path.pop_back ();
609611 mSettings .buildDir = std::move (path);
610- if (endsWith (mSettings .buildDir , ' /' ))
611- mSettings .buildDir .pop_back ();
612612 }
613613
614614 else if (std::strcmp (argv[i], " --cpp-header-probe" ) == 0 ) {
@@ -992,10 +992,8 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
992992 }
993993
994994 else if (std::strncmp (argv[i], " --max-template-recursion=" , 25 ) == 0 ) {
995- int temp = 0 ;
996- if (!parseNumberArg (argv[i], 25 , temp))
995+ if (!parseNumberArg (argv[i], 25 , mSettings .maxTemplateRecursion ))
997996 return Result::Fail;
998- mSettings .maxTemplateRecursion = temp;
999997 }
1000998
1001999 // undocumented option for usage in Python tests to indicate that no build dir should be injected
@@ -1013,6 +1011,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
10131011
10141012 else if (std::strncmp (argv[i], " --output-format=" , 16 ) == 0 ) {
10151013 const std::string format = argv[i] + 16 ;
1014+ // TODO: text and plist is missing
10161015 if (format == " sarif" )
10171016 mSettings .outputFormat = Settings::OutputFormat::sarif;
10181017 else if (format == " xml" )
@@ -1021,7 +1020,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
10211020 mLogger .printError (" argument to '--output-format=' must be 'sarif' or 'xml'." );
10221021 return Result::Fail;
10231022 }
1024- mSettings .xml = (mSettings .outputFormat == Settings::OutputFormat::xml);
10251023 }
10261024
10271025
@@ -1064,12 +1062,11 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
10641062
10651063 // Write results in results.plist
10661064 else if (std::strncmp (argv[i], " --plist-output=" , 15 ) == 0 ) {
1067- mSettings .outputFormat = Settings::OutputFormat::plist;
1068- mSettings .plistOutput = Path::simplifyPath (argv[i] + 15 );
1069- if (mSettings .plistOutput .empty ())
1070- mSettings .plistOutput = " ." ;
1065+ std::string path = Path::simplifyPath (argv[i] + 15 );
1066+ if (path.empty ())
1067+ path = " ." ;
10711068
1072- const std::string plistOutput = Path::toNativeSeparators (mSettings . plistOutput );
1069+ const std::string plistOutput = Path::toNativeSeparators (path );
10731070 if (!Path::isDirectory (plistOutput)) {
10741071 std::string message (" plist folder does not exist: '" );
10751072 message += plistOutput;
@@ -1078,8 +1075,11 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
10781075 return Result::Fail;
10791076 }
10801077
1081- if (!endsWith (mSettings .plistOutput ,' /' ))
1082- mSettings .plistOutput += ' /' ;
1078+ if (!endsWith (path,' /' ))
1079+ path += ' /' ;
1080+
1081+ mSettings .outputFormat = Settings::OutputFormat::plist;
1082+ mSettings .plistOutput = std::move (path);
10831083 }
10841084
10851085 // Special Cppcheck Premium options
@@ -1226,10 +1226,8 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
12261226 }
12271227
12281228 else if (std::strncmp (argv[i], " --report-progress=" , 18 ) == 0 ) {
1229- int tmp;
1230- if (!parseNumberArg (argv[i], 18 , tmp, true ))
1229+ if (!parseNumberArg (argv[i], 18 , mSettings .reportProgress , true ))
12311230 return Result::Fail;
1232- mSettings .reportProgress = tmp;
12331231 }
12341232
12351233 else if (std::strncmp (argv[i], " --report-type=" , 14 ) == 0 ) {
@@ -1501,7 +1499,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
15011499
15021500 // Write results in results.xml
15031501 else if (std::strcmp (argv[i], " --xml" ) == 0 ) {
1504- mSettings .xml = true ;
15051502 mSettings .outputFormat = Settings::OutputFormat::xml;
15061503 }
15071504
@@ -1518,7 +1515,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
15181515
15191516 mSettings .xml_version = tmp;
15201517 // Enable also XML if version is set
1521- mSettings .xml = true ;
15221518 mSettings .outputFormat = Settings::OutputFormat::xml;
15231519 }
15241520
0 commit comments