Updated variable names according to naming convention

This commit is contained in:
Daniel Marjamäki 2018-08-18 15:45:42 +02:00
parent fd49112196
commit 5ebfa035aa
2 changed files with 140 additions and 140 deletions

View File

@ -94,11 +94,11 @@ static void AddPathsToSet(const std::string& FileName, std::set<std::string>* se
} }
CmdLineParser::CmdLineParser(Settings *settings) CmdLineParser::CmdLineParser(Settings *settings)
: _settings(settings) : mSettings(settings)
, _showHelp(false) , mShowHelp(false)
, _showVersion(false) , mShowVersion(false)
, _showErrorMessages(false) , mShowErrorMessages(false)
, _exitAfterPrint(false) , mExitAfterPrint(false)
{ {
} }
@ -120,45 +120,45 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
if (argv[i][0] == '-') { if (argv[i][0] == '-') {
if (std::strcmp(argv[i], "--version") == 0) { if (std::strcmp(argv[i], "--version") == 0) {
_showVersion = true; mShowVersion = true;
_exitAfterPrint = true; mExitAfterPrint = true;
return true; return true;
} }
else if (std::strncmp(argv[i], "--cppcheck-build-dir=", 21) == 0) { else if (std::strncmp(argv[i], "--cppcheck-build-dir=", 21) == 0) {
_settings->buildDir = Path::fromNativeSeparators(argv[i] + 21); mSettings->buildDir = Path::fromNativeSeparators(argv[i] + 21);
if (endsWith(_settings->buildDir, '/')) if (endsWith(mSettings->buildDir, '/'))
_settings->buildDir.erase(_settings->buildDir.size() - 1U); mSettings->buildDir.erase(mSettings->buildDir.size() - 1U);
} }
// Flag used for various purposes during debugging // Flag used for various purposes during debugging
else if (std::strcmp(argv[i], "--debug-simplified") == 0) else if (std::strcmp(argv[i], "--debug-simplified") == 0)
_settings->debugSimplified = true; mSettings->debugSimplified = true;
// Show --debug output after the first simplifications // Show --debug output after the first simplifications
else if (std::strcmp(argv[i], "--debug-normal") == 0) else if (std::strcmp(argv[i], "--debug-normal") == 0)
_settings->debugnormal = true; mSettings->debugnormal = true;
// Show debug warnings // Show debug warnings
else if (std::strcmp(argv[i], "--debug-warnings") == 0) else if (std::strcmp(argv[i], "--debug-warnings") == 0)
_settings->debugwarnings = true; mSettings->debugwarnings = true;
// dump cppcheck data // dump cppcheck data
else if (std::strcmp(argv[i], "--dump") == 0) else if (std::strcmp(argv[i], "--dump") == 0)
_settings->dump = true; mSettings->dump = true;
// (Experimental) exception handling inside cppcheck client // (Experimental) exception handling inside cppcheck client
else if (std::strcmp(argv[i], "--exception-handling") == 0) else if (std::strcmp(argv[i], "--exception-handling") == 0)
_settings->exceptionHandling = true; mSettings->exceptionHandling = true;
else if (std::strncmp(argv[i], "--exception-handling=", 21) == 0) { else if (std::strncmp(argv[i], "--exception-handling=", 21) == 0) {
_settings->exceptionHandling = true; mSettings->exceptionHandling = true;
const std::string exceptionOutfilename = &(argv[i][21]); const std::string exceptionOutfilename = &(argv[i][21]);
CppCheckExecutor::setExceptionOutput((exceptionOutfilename=="stderr") ? stderr : stdout); CppCheckExecutor::setExceptionOutput((exceptionOutfilename=="stderr") ? stderr : stdout);
} }
// Inconclusive checking // Inconclusive checking
else if (std::strcmp(argv[i], "--inconclusive") == 0) else if (std::strcmp(argv[i], "--inconclusive") == 0)
_settings->inconclusive = true; mSettings->inconclusive = true;
// Enforce language (--language=, -x) // Enforce language (--language=, -x)
else if (std::strncmp(argv[i], "--language=", 11) == 0 || std::strcmp(argv[i], "-x") == 0) { else if (std::strncmp(argv[i], "--language=", 11) == 0 || std::strcmp(argv[i], "-x") == 0) {
@ -175,9 +175,9 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
} }
if (str == "c") if (str == "c")
_settings->enforcedLang = Settings::C; mSettings->enforcedLang = Settings::C;
else if (str == "c++") else if (str == "c++")
_settings->enforcedLang = Settings::CPP; mSettings->enforcedLang = Settings::CPP;
else { else {
printMessage("cppcheck: Unknown language '" + str + "' enforced."); printMessage("cppcheck: Unknown language '" + str + "' enforced.");
return false; return false;
@ -194,7 +194,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
printMessage("cppcheck: Couldn't open the file: \"" + filename + "\"."); printMessage("cppcheck: Couldn't open the file: \"" + filename + "\".");
return false; return false;
} }
const std::string errmsg(_settings->nofail.parseFile(f)); const std::string errmsg(mSettings->nofail.parseFile(f));
if (!errmsg.empty()) { if (!errmsg.empty()) {
printMessage(errmsg); printMessage(errmsg);
return false; return false;
@ -221,7 +221,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
printMessage(message); printMessage(message);
return false; return false;
} }
const std::string errmsg(_settings->nomsg.parseFile(f)); const std::string errmsg(mSettings->nomsg.parseFile(f));
if (!errmsg.empty()) { if (!errmsg.empty()) {
printMessage(errmsg); printMessage(errmsg);
return false; return false;
@ -230,7 +230,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
else if (std::strncmp(argv[i], "--suppress-xml=", 15) == 0) { else if (std::strncmp(argv[i], "--suppress-xml=", 15) == 0) {
const char * filename = argv[i] + 15; const char * filename = argv[i] + 15;
const std::string errmsg(_settings->nomsg.parseXmlFile(filename)); const std::string errmsg(mSettings->nomsg.parseXmlFile(filename));
if (!errmsg.empty()) { if (!errmsg.empty()) {
printMessage(errmsg); printMessage(errmsg);
return false; return false;
@ -239,7 +239,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
else if (std::strncmp(argv[i], "--suppress=", 11) == 0) { else if (std::strncmp(argv[i], "--suppress=", 11) == 0) {
const std::string suppression = argv[i]+11; const std::string suppression = argv[i]+11;
const std::string errmsg(_settings->nomsg.addSuppressionLine(suppression)); const std::string errmsg(mSettings->nomsg.addSuppressionLine(suppression));
if (!errmsg.empty()) { if (!errmsg.empty()) {
printMessage(errmsg); printMessage(errmsg);
return false; return false;
@ -248,30 +248,30 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
// Enables inline suppressions. // Enables inline suppressions.
else if (std::strcmp(argv[i], "--inline-suppr") == 0) else if (std::strcmp(argv[i], "--inline-suppr") == 0)
_settings->inlineSuppressions = true; mSettings->inlineSuppressions = true;
// Verbose error messages (configuration info) // Verbose error messages (configuration info)
else if (std::strcmp(argv[i], "-v") == 0 || std::strcmp(argv[i], "--verbose") == 0) else if (std::strcmp(argv[i], "-v") == 0 || std::strcmp(argv[i], "--verbose") == 0)
_settings->verbose = true; mSettings->verbose = true;
// Force checking of files that have "too many" configurations // Force checking of files that have "too many" configurations
else if (std::strcmp(argv[i], "-f") == 0 || std::strcmp(argv[i], "--force") == 0) else if (std::strcmp(argv[i], "-f") == 0 || std::strcmp(argv[i], "--force") == 0)
_settings->force = true; mSettings->force = true;
// Output relative paths // Output relative paths
else if (std::strcmp(argv[i], "-rp") == 0 || std::strcmp(argv[i], "--relative-paths") == 0) else if (std::strcmp(argv[i], "-rp") == 0 || std::strcmp(argv[i], "--relative-paths") == 0)
_settings->relativePaths = true; mSettings->relativePaths = true;
else if (std::strncmp(argv[i], "-rp=", 4) == 0 || std::strncmp(argv[i], "--relative-paths=", 17) == 0) { else if (std::strncmp(argv[i], "-rp=", 4) == 0 || std::strncmp(argv[i], "--relative-paths=", 17) == 0) {
_settings->relativePaths = true; mSettings->relativePaths = true;
if (argv[i][argv[i][3]=='='?4:17] != 0) { if (argv[i][argv[i][3]=='='?4:17] != 0) {
std::string paths = argv[i]+(argv[i][3]=='='?4:17); std::string paths = argv[i]+(argv[i][3]=='='?4:17);
for (;;) { for (;;) {
const std::string::size_type pos = paths.find(';'); const std::string::size_type pos = paths.find(';');
if (pos == std::string::npos) { if (pos == std::string::npos) {
_settings->basePaths.push_back(Path::fromNativeSeparators(paths)); mSettings->basePaths.push_back(Path::fromNativeSeparators(paths));
break; break;
} }
_settings->basePaths.push_back(Path::fromNativeSeparators(paths.substr(0, pos))); mSettings->basePaths.push_back(Path::fromNativeSeparators(paths.substr(0, pos)));
paths.erase(0, pos + 1); paths.erase(0, pos + 1);
} }
} else { } else {
@ -282,66 +282,66 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
// Write results in file // Write results in file
else if (std::strncmp(argv[i], "--output-file=", 14) == 0) else if (std::strncmp(argv[i], "--output-file=", 14) == 0)
_settings->outputFile = Path::simplifyPath(Path::fromNativeSeparators(argv[i] + 14)); mSettings->outputFile = Path::simplifyPath(Path::fromNativeSeparators(argv[i] + 14));
// Write results in results.plist // Write results in results.plist
else if (std::strncmp(argv[i], "--plist-output=", 15) == 0) { else if (std::strncmp(argv[i], "--plist-output=", 15) == 0) {
_settings->plistOutput = Path::simplifyPath(Path::fromNativeSeparators(argv[i] + 15)); mSettings->plistOutput = Path::simplifyPath(Path::fromNativeSeparators(argv[i] + 15));
if (_settings->plistOutput.empty()) if (mSettings->plistOutput.empty())
_settings->plistOutput = "./"; mSettings->plistOutput = "./";
else if (!endsWith(_settings->plistOutput,'/')) else if (!endsWith(mSettings->plistOutput,'/'))
_settings->plistOutput += '/'; mSettings->plistOutput += '/';
} }
// Write results in results.xml // Write results in results.xml
else if (std::strcmp(argv[i], "--xml") == 0) else if (std::strcmp(argv[i], "--xml") == 0)
_settings->xml = true; mSettings->xml = true;
// Define the XML file version (and enable XML output) // Define the XML file version (and enable XML output)
else if (std::strncmp(argv[i], "--xml-version=", 14) == 0) { else if (std::strncmp(argv[i], "--xml-version=", 14) == 0) {
const std::string numberString(argv[i]+14); const std::string numberString(argv[i]+14);
std::istringstream iss(numberString); std::istringstream iss(numberString);
if (!(iss >> _settings->xml_version)) { if (!(iss >> mSettings->xml_version)) {
printMessage("cppcheck: argument to '--xml-version' is not a number."); printMessage("cppcheck: argument to '--xml-version' is not a number.");
return false; return false;
} }
if (_settings->xml_version != 2) { if (mSettings->xml_version != 2) {
// We only have xml version 2 // We only have xml version 2
printMessage("cppcheck: '--xml-version' can only be 2."); printMessage("cppcheck: '--xml-version' can only be 2.");
return false; return false;
} }
// Enable also XML if version is set // Enable also XML if version is set
_settings->xml = true; mSettings->xml = true;
} }
// Only print something when there are errors // Only print something when there are errors
else if (std::strcmp(argv[i], "-q") == 0 || std::strcmp(argv[i], "--quiet") == 0) else if (std::strcmp(argv[i], "-q") == 0 || std::strcmp(argv[i], "--quiet") == 0)
_settings->quiet = true; mSettings->quiet = true;
// Check configuration // Check configuration
else if (std::strcmp(argv[i], "--check-config") == 0) { else if (std::strcmp(argv[i], "--check-config") == 0) {
_settings->checkConfiguration = true; mSettings->checkConfiguration = true;
} }
// Check library definitions // Check library definitions
else if (std::strcmp(argv[i], "--check-library") == 0) { else if (std::strcmp(argv[i], "--check-library") == 0) {
_settings->checkLibrary = true; mSettings->checkLibrary = true;
} }
else if (std::strncmp(argv[i], "--enable=", 9) == 0) { else if (std::strncmp(argv[i], "--enable=", 9) == 0) {
const std::string errmsg = _settings->addEnabled(argv[i] + 9); const std::string errmsg = mSettings->addEnabled(argv[i] + 9);
if (!errmsg.empty()) { if (!errmsg.empty()) {
printMessage(errmsg); printMessage(errmsg);
return false; return false;
} }
// when "style" is enabled, also enable "warning", "performance" and "portability" // when "style" is enabled, also enable "warning", "performance" and "portability"
if (_settings->isEnabled(Settings::STYLE)) { if (mSettings->isEnabled(Settings::STYLE)) {
_settings->addEnabled("warning"); mSettings->addEnabled("warning");
_settings->addEnabled("performance"); mSettings->addEnabled("performance");
_settings->addEnabled("portability"); mSettings->addEnabled("portability");
} }
} }
@ -349,8 +349,8 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
else if (std::strncmp(argv[i], "--error-exitcode=", 17) == 0) { else if (std::strncmp(argv[i], "--error-exitcode=", 17) == 0) {
const std::string temp = argv[i]+17; const std::string temp = argv[i]+17;
std::istringstream iss(temp); std::istringstream iss(temp);
if (!(iss >> _settings->exitCode)) { if (!(iss >> mSettings->exitCode)) {
_settings->exitCode = 0; mSettings->exitCode = 0;
printMessage("cppcheck: Argument must be an integer. Try something like '--error-exitcode=1'."); printMessage("cppcheck: Argument must be an integer. Try something like '--error-exitcode=1'.");
return false; return false;
} }
@ -379,9 +379,9 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
if (define.find('=') == std::string::npos) if (define.find('=') == std::string::npos)
define += "=1"; define += "=1";
if (!_settings->userDefines.empty()) if (!mSettings->userDefines.empty())
_settings->userDefines += ";"; mSettings->userDefines += ";";
_settings->userDefines += define; mSettings->userDefines += define;
def = true; def = true;
} }
@ -404,12 +404,12 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
undef = 2 + argv[i]; undef = 2 + argv[i];
} }
_settings->userUndefs.insert(undef); mSettings->userUndefs.insert(undef);
} }
// -E // -E
else if (std::strcmp(argv[i], "-E") == 0) { else if (std::strcmp(argv[i], "-E") == 0) {
_settings->preprocessOnly = true; mSettings->preprocessOnly = true;
} }
// Include paths // Include paths
@ -437,29 +437,29 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
if (!endsWith(path,'/')) if (!endsWith(path,'/'))
path += '/'; path += '/';
_settings->includePaths.push_back(path); mSettings->includePaths.push_back(path);
} else if (std::strncmp(argv[i], "--include=", 10) == 0) { } else if (std::strncmp(argv[i], "--include=", 10) == 0) {
std::string path = argv[i] + 10; std::string path = argv[i] + 10;
path = Path::fromNativeSeparators(path); path = Path::fromNativeSeparators(path);
_settings->userIncludes.push_back(path); mSettings->userIncludes.push_back(path);
} else if (std::strncmp(argv[i], "--includes-file=", 16) == 0) { } else if (std::strncmp(argv[i], "--includes-file=", 16) == 0) {
// open this file and read every input file (1 file name per line) // open this file and read every input file (1 file name per line)
AddInclPathsToList(16 + argv[i], &_settings->includePaths); AddInclPathsToList(16 + argv[i], &mSettings->includePaths);
} else if (std::strncmp(argv[i], "--config-exclude=",17) ==0) { } else if (std::strncmp(argv[i], "--config-exclude=",17) ==0) {
std::string path = argv[i] + 17; std::string path = argv[i] + 17;
path = Path::fromNativeSeparators(path); path = Path::fromNativeSeparators(path);
_settings->configExcludePaths.insert(path); mSettings->configExcludePaths.insert(path);
} else if (std::strncmp(argv[i], "--config-excludes-file=", 23) == 0) { } else if (std::strncmp(argv[i], "--config-excludes-file=", 23) == 0) {
// open this file and read every input file (1 file name per line) // open this file and read every input file (1 file name per line)
AddPathsToSet(23 + argv[i], &_settings->configExcludePaths); AddPathsToSet(23 + argv[i], &mSettings->configExcludePaths);
} }
// file list specified // file list specified
else if (std::strncmp(argv[i], "--file-list=", 12) == 0) { else if (std::strncmp(argv[i], "--file-list=", 12) == 0) {
// open this file and read every input file (1 file name per line) // open this file and read every input file (1 file name per line)
AddFilesToList(12 + argv[i], _pathnames); AddFilesToList(12 + argv[i], mPathNames);
} }
// Ignored paths // Ignored paths
@ -491,22 +491,22 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
if (!endsWith(path, '/')) if (!endsWith(path, '/'))
path += '/'; path += '/';
} }
_ignoredPaths.push_back(path); mIgnoredPaths.push_back(path);
} }
} }
// --library // --library
else if (std::strncmp(argv[i], "--library=", 10) == 0) { else if (std::strncmp(argv[i], "--library=", 10) == 0) {
if (!CppCheckExecutor::tryLoadLibrary(_settings->library, argv[0], argv[i]+10)) if (!CppCheckExecutor::tryLoadLibrary(mSettings->library, argv[0], argv[i]+10))
return false; return false;
} }
// --project // --project
else if (std::strncmp(argv[i], "--project=", 10) == 0) { else if (std::strncmp(argv[i], "--project=", 10) == 0) {
const std::string projectFile = argv[i]+10; const std::string projectFile = argv[i]+10;
const ImportProject::Type projType = _settings->project.import(projectFile); const ImportProject::Type projType = mSettings->project.import(projectFile);
if (projType == ImportProject::VS_SLN || projType == ImportProject::VS_VCXPROJ) { if (projType == ImportProject::VS_SLN || projType == ImportProject::VS_VCXPROJ) {
if (!CppCheckExecutor::tryLoadLibrary(_settings->library, argv[0], "windows.cfg")) { if (!CppCheckExecutor::tryLoadLibrary(mSettings->library, argv[0], "windows.cfg")) {
// This shouldn't happen normally. // This shouldn't happen normally.
printMessage("cppcheck: Failed to load 'windows.cfg'. Your Cppcheck installation is broken. Please re-install."); printMessage("cppcheck: Failed to load 'windows.cfg'. Your Cppcheck installation is broken. Please re-install.");
return false; return false;
@ -524,24 +524,24 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
// Report progress // Report progress
else if (std::strcmp(argv[i], "--report-progress") == 0) { else if (std::strcmp(argv[i], "--report-progress") == 0) {
_settings->reportProgress = true; mSettings->reportProgress = true;
} }
// --std // --std
else if (std::strcmp(argv[i], "--std=posix") == 0) { else if (std::strcmp(argv[i], "--std=posix") == 0) {
_settings->standards.posix = true; mSettings->standards.posix = true;
} else if (std::strcmp(argv[i], "--std=c89") == 0) { } else if (std::strcmp(argv[i], "--std=c89") == 0) {
_settings->standards.c = Standards::C89; mSettings->standards.c = Standards::C89;
} else if (std::strcmp(argv[i], "--std=c99") == 0) { } else if (std::strcmp(argv[i], "--std=c99") == 0) {
_settings->standards.c = Standards::C99; mSettings->standards.c = Standards::C99;
} else if (std::strcmp(argv[i], "--std=c11") == 0) { } else if (std::strcmp(argv[i], "--std=c11") == 0) {
_settings->standards.c = Standards::C11; mSettings->standards.c = Standards::C11;
} else if (std::strcmp(argv[i], "--std=c++03") == 0) { } else if (std::strcmp(argv[i], "--std=c++03") == 0) {
_settings->standards.cpp = Standards::CPP03; mSettings->standards.cpp = Standards::CPP03;
} else if (std::strcmp(argv[i], "--std=c++11") == 0) { } else if (std::strcmp(argv[i], "--std=c++11") == 0) {
_settings->standards.cpp = Standards::CPP11; mSettings->standards.cpp = Standards::CPP11;
} else if (std::strcmp(argv[i], "--std=c++14") == 0) { } else if (std::strcmp(argv[i], "--std=c++14") == 0) {
_settings->standards.cpp = Standards::CPP14; mSettings->standards.cpp = Standards::CPP14;
} }
// Output formatter // Output formatter
@ -549,36 +549,36 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
std::strncmp(argv[i], "--template=", 11) == 0) { std::strncmp(argv[i], "--template=", 11) == 0) {
// "--template format" // "--template format"
if (argv[i][10] == '=') if (argv[i][10] == '=')
_settings->templateFormat = argv[i] + 11; mSettings->templateFormat = argv[i] + 11;
else if ((i+1) < argc && argv[i+1][0] != '-') { else if ((i+1) < argc && argv[i+1][0] != '-') {
++i; ++i;
_settings->templateFormat = argv[i]; mSettings->templateFormat = argv[i];
} else { } else {
printMessage("cppcheck: argument to '--template' is missing."); printMessage("cppcheck: argument to '--template' is missing.");
return false; return false;
} }
if (_settings->templateFormat == "gcc") { if (mSettings->templateFormat == "gcc") {
//_settings->templateFormat = "{file}:{line}: {severity}: {message}"; //_settings->templateFormat = "{file}:{line}: {severity}: {message}";
_settings->templateFormat = "{file}:{line}:{column}: warning: {message} [{id}]\\n{code}"; mSettings->templateFormat = "{file}:{line}:{column}: warning: {message} [{id}]\\n{code}";
_settings->templateLocation = "{file}:{line}:{column}: note: {info}\\n{code}"; mSettings->templateLocation = "{file}:{line}:{column}: note: {info}\\n{code}";
} else if (_settings->templateFormat == "daca2") { } else if (mSettings->templateFormat == "daca2") {
_settings->templateFormat = "{file}:{line}:{column}: {severity}: {message} [{id}]"; mSettings->templateFormat = "{file}:{line}:{column}: {severity}: {message} [{id}]";
_settings->templateLocation = "{file}:{line}:{column}: note: {info}"; mSettings->templateLocation = "{file}:{line}:{column}: note: {info}";
} else if (_settings->templateFormat == "vs") } else if (mSettings->templateFormat == "vs")
_settings->templateFormat = "{file}({line}): {severity}: {message}"; mSettings->templateFormat = "{file}({line}): {severity}: {message}";
else if (_settings->templateFormat == "edit") else if (mSettings->templateFormat == "edit")
_settings->templateFormat = "{file} +{line}: {severity}: {message}"; mSettings->templateFormat = "{file} +{line}: {severity}: {message}";
} }
else if (std::strcmp(argv[i], "--template-location") == 0 || else if (std::strcmp(argv[i], "--template-location") == 0 ||
std::strncmp(argv[i], "--template-location=", 20) == 0) { std::strncmp(argv[i], "--template-location=", 20) == 0) {
// "--template-location format" // "--template-location format"
if (argv[i][19] == '=') if (argv[i][19] == '=')
_settings->templateLocation = argv[i] + 20; mSettings->templateLocation = argv[i] + 20;
else if ((i+1) < argc && argv[i+1][0] != '-') { else if ((i+1) < argc && argv[i+1][0] != '-') {
++i; ++i;
_settings->templateLocation = argv[i]; mSettings->templateLocation = argv[i];
} else { } else {
printMessage("cppcheck: argument to '--template' is missing."); printMessage("cppcheck: argument to '--template' is missing.");
return false; return false;
@ -605,12 +605,12 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
numberString = argv[i]+2; numberString = argv[i]+2;
std::istringstream iss(numberString); std::istringstream iss(numberString);
if (!(iss >> _settings->jobs)) { if (!(iss >> mSettings->jobs)) {
printMessage("cppcheck: argument to '-j' is not a number."); printMessage("cppcheck: argument to '-j' is not a number.");
return false; return false;
} }
if (_settings->jobs > 10000) { if (mSettings->jobs > 10000) {
// This limit is here just to catch typos. If someone has // This limit is here just to catch typos. If someone has
// need for more jobs, this value should be increased. // need for more jobs, this value should be increased.
printMessage("cppcheck: argument for '-j' is allowed to be 10000 at max."); printMessage("cppcheck: argument for '-j' is allowed to be 10000 at max.");
@ -635,7 +635,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
numberString = argv[i]+2; numberString = argv[i]+2;
std::istringstream iss(numberString); std::istringstream iss(numberString);
if (!(iss >> _settings->loadAverage)) { if (!(iss >> mSettings->loadAverage)) {
printMessage("cppcheck: argument to '-l' is not a number."); printMessage("cppcheck: argument to '-l' is not a number.");
return false; return false;
} }
@ -643,9 +643,9 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
// print all possible error messages.. // print all possible error messages..
else if (std::strcmp(argv[i], "--errorlist") == 0) { else if (std::strcmp(argv[i], "--errorlist") == 0) {
_showErrorMessages = true; mShowErrorMessages = true;
_settings->xml = true; mSettings->xml = true;
_exitAfterPrint = true; mExitAfterPrint = true;
} }
// documentation.. // documentation..
@ -661,7 +661,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
} }
std::cout << doc.str(); std::cout << doc.str();
_exitAfterPrint = true; mExitAfterPrint = true;
return true; return true;
} }
@ -669,13 +669,13 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
else if (std::strncmp(argv[i], "--showtime=", 11) == 0) { else if (std::strncmp(argv[i], "--showtime=", 11) == 0) {
const std::string showtimeMode = argv[i] + 11; const std::string showtimeMode = argv[i] + 11;
if (showtimeMode == "file") if (showtimeMode == "file")
_settings->showtime = SHOWTIME_FILE; mSettings->showtime = SHOWTIME_FILE;
else if (showtimeMode == "summary") else if (showtimeMode == "summary")
_settings->showtime = SHOWTIME_SUMMARY; mSettings->showtime = SHOWTIME_SUMMARY;
else if (showtimeMode == "top5") else if (showtimeMode == "top5")
_settings->showtime = SHOWTIME_TOP5; mSettings->showtime = SHOWTIME_TOP5;
else if (showtimeMode.empty()) else if (showtimeMode.empty())
_settings->showtime = SHOWTIME_NONE; mSettings->showtime = SHOWTIME_NONE;
else { else {
std::string message("cppcheck: error: unrecognized showtime mode: \""); std::string message("cppcheck: error: unrecognized showtime mode: \"");
message += showtimeMode; message += showtimeMode;
@ -690,7 +690,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
else if (std::strncmp(argv[i], "--rule=", 7) == 0) { else if (std::strncmp(argv[i], "--rule=", 7) == 0) {
Settings::Rule rule; Settings::Rule rule;
rule.pattern = 7 + argv[i]; rule.pattern = 7 + argv[i];
_settings->rules.push_back(rule); mSettings->rules.push_back(rule);
} }
// Rule file // Rule file
@ -726,7 +726,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
} }
if (!rule.pattern.empty()) if (!rule.pattern.empty())
_settings->rules.push_back(rule); mSettings->rules.push_back(rule);
} }
} else { } else {
printMessage("cppcheck: error: unable to load rule-file: " + std::string(12+argv[i])); printMessage("cppcheck: error: unable to load rule-file: " + std::string(12+argv[i]));
@ -740,20 +740,20 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
const std::string platform(11+argv[i]); const std::string platform(11+argv[i]);
if (platform == "win32A") if (platform == "win32A")
_settings->platform(Settings::Win32A); mSettings->platform(Settings::Win32A);
else if (platform == "win32W") else if (platform == "win32W")
_settings->platform(Settings::Win32W); mSettings->platform(Settings::Win32W);
else if (platform == "win64") else if (platform == "win64")
_settings->platform(Settings::Win64); mSettings->platform(Settings::Win64);
else if (platform == "unix32") else if (platform == "unix32")
_settings->platform(Settings::Unix32); mSettings->platform(Settings::Unix32);
else if (platform == "unix64") else if (platform == "unix64")
_settings->platform(Settings::Unix64); mSettings->platform(Settings::Unix64);
else if (platform == "native") else if (platform == "native")
_settings->platform(Settings::Native); mSettings->platform(Settings::Native);
else if (platform == "unspecified") else if (platform == "unspecified")
_settings->platform(Settings::Unspecified); mSettings->platform(Settings::Unspecified);
else if (!_settings->loadPlatformFile(argv[0], platform)) { else if (!mSettings->loadPlatformFile(argv[0], platform)) {
std::string message("cppcheck: error: unrecognized platform: \""); std::string message("cppcheck: error: unrecognized platform: \"");
message += platform; message += platform;
message += "\"."; message += "\".";
@ -764,15 +764,15 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
// Set maximum number of #ifdef configurations to check // Set maximum number of #ifdef configurations to check
else if (std::strncmp(argv[i], "--max-configs=", 14) == 0) { else if (std::strncmp(argv[i], "--max-configs=", 14) == 0) {
_settings->force = false; mSettings->force = false;
std::istringstream iss(14+argv[i]); std::istringstream iss(14+argv[i]);
if (!(iss >> _settings->maxConfigs)) { if (!(iss >> mSettings->maxConfigs)) {
printMessage("cppcheck: argument to '--max-configs=' is not a number."); printMessage("cppcheck: argument to '--max-configs=' is not a number.");
return false; return false;
} }
if (_settings->maxConfigs < 1) { if (mSettings->maxConfigs < 1) {
printMessage("cppcheck: argument to '--max-configs=' must be greater than 0."); printMessage("cppcheck: argument to '--max-configs=' must be greater than 0.");
return false; return false;
} }
@ -782,9 +782,9 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
// Print help // Print help
else if (std::strcmp(argv[i], "-h") == 0 || std::strcmp(argv[i], "--help") == 0) { else if (std::strcmp(argv[i], "-h") == 0 || std::strcmp(argv[i], "--help") == 0) {
_pathnames.clear(); mPathNames.clear();
_showHelp = true; mShowHelp = true;
_exitAfterPrint = true; mExitAfterPrint = true;
break; break;
} }
@ -800,41 +800,41 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
else { else {
std::string path = Path::removeQuotationMarks(argv[i]); std::string path = Path::removeQuotationMarks(argv[i]);
path = Path::fromNativeSeparators(path); path = Path::fromNativeSeparators(path);
_pathnames.push_back(path); mPathNames.push_back(path);
} }
} }
_settings->project.ignorePaths(_ignoredPaths); mSettings->project.ignorePaths(mIgnoredPaths);
if (_settings->force) if (mSettings->force)
_settings->maxConfigs = ~0U; mSettings->maxConfigs = ~0U;
else if ((def || _settings->preprocessOnly) && !maxconfigs) else if ((def || mSettings->preprocessOnly) && !maxconfigs)
_settings->maxConfigs = 1U; mSettings->maxConfigs = 1U;
if (_settings->isEnabled(Settings::UNUSED_FUNCTION) && _settings->jobs > 1) { if (mSettings->isEnabled(Settings::UNUSED_FUNCTION) && mSettings->jobs > 1) {
printMessage("cppcheck: unusedFunction check can't be used with '-j' option. Disabling unusedFunction check."); printMessage("cppcheck: unusedFunction check can't be used with '-j' option. Disabling unusedFunction check.");
} }
if (argc <= 1) { if (argc <= 1) {
_showHelp = true; mShowHelp = true;
_exitAfterPrint = true; mExitAfterPrint = true;
} }
if (_showHelp) { if (mShowHelp) {
printHelp(); printHelp();
return true; return true;
} }
// Print error only if we have "real" command and expect files // Print error only if we have "real" command and expect files
if (!_exitAfterPrint && _pathnames.empty() && _settings->project.fileSettings.empty()) { if (!mExitAfterPrint && mPathNames.empty() && mSettings->project.fileSettings.empty()) {
printMessage("cppcheck: No C or C++ source files found."); printMessage("cppcheck: No C or C++ source files found.");
return false; return false;
} }
// Use paths _pathnames if no base paths for relative path output are given // Use paths _pathnames if no base paths for relative path output are given
if (_settings->basePaths.empty() && _settings->relativePaths) if (mSettings->basePaths.empty() && mSettings->relativePaths)
_settings->basePaths = _pathnames; mSettings->basePaths = mPathNames;
return true; return true;
} }

View File

@ -55,42 +55,42 @@ public:
* Return if user wanted to see program version. * Return if user wanted to see program version.
*/ */
bool getShowVersion() const { bool getShowVersion() const {
return _showVersion; return mShowVersion;
} }
/** /**
* Return if user wanted to see list of error messages. * Return if user wanted to see list of error messages.
*/ */
bool getShowErrorMessages() const { bool getShowErrorMessages() const {
return _showErrorMessages; return mShowErrorMessages;
} }
/** /**
* Return the path names user gave to command line. * Return the path names user gave to command line.
*/ */
const std::vector<std::string>& getPathNames() const { const std::vector<std::string>& getPathNames() const {
return _pathnames; return mPathNames;
} }
/** /**
* Return if help is shown to user. * Return if help is shown to user.
*/ */
bool getShowHelp() const { bool getShowHelp() const {
return _showHelp; return mShowHelp;
} }
/** /**
* Return if we should exit after printing version, help etc. * Return if we should exit after printing version, help etc.
*/ */
bool exitAfterPrinting() const { bool exitAfterPrinting() const {
return _exitAfterPrint; return mExitAfterPrint;
} }
/** /**
* Return a list of paths user wants to ignore. * Return a list of paths user wants to ignore.
*/ */
const std::vector<std::string>& getIgnoredPaths() const { const std::vector<std::string>& getIgnoredPaths() const {
return _ignoredPaths; return mIgnoredPaths;
} }
protected: protected:
@ -107,13 +107,13 @@ protected:
static void printMessage(const char* message); static void printMessage(const char* message);
private: private:
std::vector<std::string> _pathnames; std::vector<std::string> mPathNames;
std::vector<std::string> _ignoredPaths; std::vector<std::string> mIgnoredPaths;
Settings *_settings; Settings *mSettings;
bool _showHelp; bool mShowHelp;
bool _showVersion; bool mShowVersion;
bool _showErrorMessages; bool mShowErrorMessages;
bool _exitAfterPrint; bool mExitAfterPrint;
}; };
/// @} /// @}