@@ -603,25 +603,10 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
603603 else if (std::strncmp (argv[i], " --platform=" , 11 ) == 0 ) {
604604 const std::string platform (11 +argv[i]);
605605
606- if (platform == " win32A" )
607- mSettings ->platform (Settings::Win32A);
608- else if (platform == " win32W" )
609- mSettings ->platform (Settings::Win32W);
610- else if (platform == " win64" )
611- mSettings ->platform (Settings::Win64);
612- else if (platform == " unix32" )
613- mSettings ->platform (Settings::Unix32);
614- else if (platform == " unix64" )
615- mSettings ->platform (Settings::Unix64);
616- else if (platform == " native" )
617- mSettings ->platform (Settings::Native);
618- else if (platform == " unspecified" )
619- mSettings ->platform (Settings::Unspecified);
620- else if (!mSettings ->loadPlatformFile (argv[0 ], platform, mSettings ->verbose )) {
621- std::string message (" unrecognized platform: \" " );
622- message += platform;
623- message += " \" ." ;
624- printError (message);
606+ std::string errstr;
607+ const std::vector<std::string> paths = {argv[0 ]};
608+ if (!mSettings ->platform (platform, errstr, paths)) {
609+ printError (errstr);
625610 return false ;
626611 }
627612
@@ -669,7 +654,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
669654 // --project
670655 else if (std::strncmp (argv[i], " --project=" , 10 ) == 0 ) {
671656 mSettings ->checkAllConfigurations = false ; // Can be overridden with --max-configs or --force
672- const std::string projectFile = argv[i]+10 ;
657+ std::string projectFile = argv[i]+10 ;
673658 ImportProject::Type projType = mSettings ->project .import (projectFile, mSettings );
674659 mSettings ->project .projectType = projType;
675660 if (projType == ImportProject::Type::CPPCHECK_GUI) {
@@ -680,32 +665,27 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
680665 const auto & excludedPaths = mSettings ->project .guiProject .excludedPaths ;
681666 std::copy (excludedPaths.cbegin (), excludedPaths.cend (), std::back_inserter (mIgnoredPaths ));
682667
683- const std::string platform (mSettings ->project .guiProject .platform );
684-
685- if (platform == " win32A" )
686- mSettings ->platform (Settings::Win32A);
687- else if (platform == " win32W" )
688- mSettings ->platform (Settings::Win32W);
689- else if (platform == " win64" )
690- mSettings ->platform (Settings::Win64);
691- else if (platform == " unix32" )
692- mSettings ->platform (Settings::Unix32);
693- else if (platform == " unix64" )
694- mSettings ->platform (Settings::Unix64);
695- else if (platform == " native" )
696- mSettings ->platform (Settings::Native);
697- else if (platform == " unspecified" || platform == " Unspecified" || platform.empty ())
698- ;
699- else if (!mSettings ->loadPlatformFile (projectFile.c_str (), platform, mSettings ->verbose ) && !mSettings ->loadPlatformFile (argv[0 ], platform, mSettings ->verbose )) {
700- std::string message (" unrecognized platform: \" " );
701- message += platform;
702- message += " \" ." ;
703- printError (message);
704- return false ;
668+ std::string platform (mSettings ->project .guiProject .platform );
669+
670+ // keep existing platform from command-line intact
671+ if (!platform.empty ()) {
672+ if (platform == " Unspecified" ) {
673+ printMessage (" 'Unspecified' is a deprecated platform type and will be removed in Cppcheck 2.14. Please use 'unspecified' instead." );
674+ platform = " unspecified" ;
675+ }
676+
677+ std::string errstr;
678+ const std::vector<std::string> paths = {projectFile, argv[0 ]};
679+ if (!mSettings ->platform (platform, errstr, paths)) {
680+ printError (errstr);
681+ return false ;
682+ }
705683 }
706684
707- if (!mSettings ->project .guiProject .projectFile .empty ())
685+ if (!mSettings ->project .guiProject .projectFile .empty ()) {
686+ projectFile = mSettings ->project .guiProject .projectFile ;
708687 projType = mSettings ->project .import (mSettings ->project .guiProject .projectFile , mSettings );
688+ }
709689 }
710690 if (projType == ImportProject::Type::VS_SLN || projType == ImportProject::Type::VS_VCXPROJ) {
711691 if (mSettings ->project .guiProject .analyzeAllVsConfigs == " false" )
0 commit comments