Updated variable names according to naming convention
This commit is contained in:
parent
fd49112196
commit
5ebfa035aa
|
@ -94,11 +94,11 @@ static void AddPathsToSet(const std::string& FileName, std::set<std::string>* se
|
|||
}
|
||||
|
||||
CmdLineParser::CmdLineParser(Settings *settings)
|
||||
: _settings(settings)
|
||||
, _showHelp(false)
|
||||
, _showVersion(false)
|
||||
, _showErrorMessages(false)
|
||||
, _exitAfterPrint(false)
|
||||
: mSettings(settings)
|
||||
, mShowHelp(false)
|
||||
, mShowVersion(false)
|
||||
, mShowErrorMessages(false)
|
||||
, mExitAfterPrint(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -120,45 +120,45 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
for (int i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
if (std::strcmp(argv[i], "--version") == 0) {
|
||||
_showVersion = true;
|
||||
_exitAfterPrint = true;
|
||||
mShowVersion = true;
|
||||
mExitAfterPrint = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
else if (std::strncmp(argv[i], "--cppcheck-build-dir=", 21) == 0) {
|
||||
_settings->buildDir = Path::fromNativeSeparators(argv[i] + 21);
|
||||
if (endsWith(_settings->buildDir, '/'))
|
||||
_settings->buildDir.erase(_settings->buildDir.size() - 1U);
|
||||
mSettings->buildDir = Path::fromNativeSeparators(argv[i] + 21);
|
||||
if (endsWith(mSettings->buildDir, '/'))
|
||||
mSettings->buildDir.erase(mSettings->buildDir.size() - 1U);
|
||||
}
|
||||
|
||||
// Flag used for various purposes during debugging
|
||||
else if (std::strcmp(argv[i], "--debug-simplified") == 0)
|
||||
_settings->debugSimplified = true;
|
||||
mSettings->debugSimplified = true;
|
||||
|
||||
// Show --debug output after the first simplifications
|
||||
else if (std::strcmp(argv[i], "--debug-normal") == 0)
|
||||
_settings->debugnormal = true;
|
||||
mSettings->debugnormal = true;
|
||||
|
||||
// Show debug warnings
|
||||
else if (std::strcmp(argv[i], "--debug-warnings") == 0)
|
||||
_settings->debugwarnings = true;
|
||||
mSettings->debugwarnings = true;
|
||||
|
||||
// dump cppcheck data
|
||||
else if (std::strcmp(argv[i], "--dump") == 0)
|
||||
_settings->dump = true;
|
||||
mSettings->dump = true;
|
||||
|
||||
// (Experimental) exception handling inside cppcheck client
|
||||
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) {
|
||||
_settings->exceptionHandling = true;
|
||||
mSettings->exceptionHandling = true;
|
||||
const std::string exceptionOutfilename = &(argv[i][21]);
|
||||
CppCheckExecutor::setExceptionOutput((exceptionOutfilename=="stderr") ? stderr : stdout);
|
||||
}
|
||||
|
||||
// Inconclusive checking
|
||||
else if (std::strcmp(argv[i], "--inconclusive") == 0)
|
||||
_settings->inconclusive = true;
|
||||
mSettings->inconclusive = true;
|
||||
|
||||
// Enforce language (--language=, -x)
|
||||
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")
|
||||
_settings->enforcedLang = Settings::C;
|
||||
mSettings->enforcedLang = Settings::C;
|
||||
else if (str == "c++")
|
||||
_settings->enforcedLang = Settings::CPP;
|
||||
mSettings->enforcedLang = Settings::CPP;
|
||||
else {
|
||||
printMessage("cppcheck: Unknown language '" + str + "' enforced.");
|
||||
return false;
|
||||
|
@ -194,7 +194,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
printMessage("cppcheck: Couldn't open the file: \"" + filename + "\".");
|
||||
return false;
|
||||
}
|
||||
const std::string errmsg(_settings->nofail.parseFile(f));
|
||||
const std::string errmsg(mSettings->nofail.parseFile(f));
|
||||
if (!errmsg.empty()) {
|
||||
printMessage(errmsg);
|
||||
return false;
|
||||
|
@ -221,7 +221,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
printMessage(message);
|
||||
return false;
|
||||
}
|
||||
const std::string errmsg(_settings->nomsg.parseFile(f));
|
||||
const std::string errmsg(mSettings->nomsg.parseFile(f));
|
||||
if (!errmsg.empty()) {
|
||||
printMessage(errmsg);
|
||||
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) {
|
||||
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()) {
|
||||
printMessage(errmsg);
|
||||
return false;
|
||||
|
@ -239,7 +239,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
else if (std::strncmp(argv[i], "--suppress=", 11) == 0) {
|
||||
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()) {
|
||||
printMessage(errmsg);
|
||||
return false;
|
||||
|
@ -248,30 +248,30 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
// Enables inline suppressions.
|
||||
else if (std::strcmp(argv[i], "--inline-suppr") == 0)
|
||||
_settings->inlineSuppressions = true;
|
||||
mSettings->inlineSuppressions = true;
|
||||
|
||||
// Verbose error messages (configuration info)
|
||||
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
|
||||
else if (std::strcmp(argv[i], "-f") == 0 || std::strcmp(argv[i], "--force") == 0)
|
||||
_settings->force = true;
|
||||
mSettings->force = true;
|
||||
|
||||
// Output relative paths
|
||||
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) {
|
||||
_settings->relativePaths = true;
|
||||
mSettings->relativePaths = true;
|
||||
if (argv[i][argv[i][3]=='='?4:17] != 0) {
|
||||
std::string paths = argv[i]+(argv[i][3]=='='?4:17);
|
||||
for (;;) {
|
||||
const std::string::size_type pos = paths.find(';');
|
||||
if (pos == std::string::npos) {
|
||||
_settings->basePaths.push_back(Path::fromNativeSeparators(paths));
|
||||
mSettings->basePaths.push_back(Path::fromNativeSeparators(paths));
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
|
@ -282,66 +282,66 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
// Write results in file
|
||||
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
|
||||
else if (std::strncmp(argv[i], "--plist-output=", 15) == 0) {
|
||||
_settings->plistOutput = Path::simplifyPath(Path::fromNativeSeparators(argv[i] + 15));
|
||||
if (_settings->plistOutput.empty())
|
||||
_settings->plistOutput = "./";
|
||||
else if (!endsWith(_settings->plistOutput,'/'))
|
||||
_settings->plistOutput += '/';
|
||||
mSettings->plistOutput = Path::simplifyPath(Path::fromNativeSeparators(argv[i] + 15));
|
||||
if (mSettings->plistOutput.empty())
|
||||
mSettings->plistOutput = "./";
|
||||
else if (!endsWith(mSettings->plistOutput,'/'))
|
||||
mSettings->plistOutput += '/';
|
||||
}
|
||||
|
||||
// Write results in results.xml
|
||||
else if (std::strcmp(argv[i], "--xml") == 0)
|
||||
_settings->xml = true;
|
||||
mSettings->xml = true;
|
||||
|
||||
// Define the XML file version (and enable XML output)
|
||||
else if (std::strncmp(argv[i], "--xml-version=", 14) == 0) {
|
||||
const std::string numberString(argv[i]+14);
|
||||
|
||||
std::istringstream iss(numberString);
|
||||
if (!(iss >> _settings->xml_version)) {
|
||||
if (!(iss >> mSettings->xml_version)) {
|
||||
printMessage("cppcheck: argument to '--xml-version' is not a number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_settings->xml_version != 2) {
|
||||
if (mSettings->xml_version != 2) {
|
||||
// We only have xml version 2
|
||||
printMessage("cppcheck: '--xml-version' can only be 2.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enable also XML if version is set
|
||||
_settings->xml = true;
|
||||
mSettings->xml = true;
|
||||
}
|
||||
|
||||
// Only print something when there are errors
|
||||
else if (std::strcmp(argv[i], "-q") == 0 || std::strcmp(argv[i], "--quiet") == 0)
|
||||
_settings->quiet = true;
|
||||
mSettings->quiet = true;
|
||||
|
||||
// Check configuration
|
||||
else if (std::strcmp(argv[i], "--check-config") == 0) {
|
||||
_settings->checkConfiguration = true;
|
||||
mSettings->checkConfiguration = true;
|
||||
}
|
||||
|
||||
// Check library definitions
|
||||
else if (std::strcmp(argv[i], "--check-library") == 0) {
|
||||
_settings->checkLibrary = true;
|
||||
mSettings->checkLibrary = true;
|
||||
}
|
||||
|
||||
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()) {
|
||||
printMessage(errmsg);
|
||||
return false;
|
||||
}
|
||||
// when "style" is enabled, also enable "warning", "performance" and "portability"
|
||||
if (_settings->isEnabled(Settings::STYLE)) {
|
||||
_settings->addEnabled("warning");
|
||||
_settings->addEnabled("performance");
|
||||
_settings->addEnabled("portability");
|
||||
if (mSettings->isEnabled(Settings::STYLE)) {
|
||||
mSettings->addEnabled("warning");
|
||||
mSettings->addEnabled("performance");
|
||||
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) {
|
||||
const std::string temp = argv[i]+17;
|
||||
std::istringstream iss(temp);
|
||||
if (!(iss >> _settings->exitCode)) {
|
||||
_settings->exitCode = 0;
|
||||
if (!(iss >> mSettings->exitCode)) {
|
||||
mSettings->exitCode = 0;
|
||||
printMessage("cppcheck: Argument must be an integer. Try something like '--error-exitcode=1'.");
|
||||
return false;
|
||||
}
|
||||
|
@ -379,9 +379,9 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
if (define.find('=') == std::string::npos)
|
||||
define += "=1";
|
||||
|
||||
if (!_settings->userDefines.empty())
|
||||
_settings->userDefines += ";";
|
||||
_settings->userDefines += define;
|
||||
if (!mSettings->userDefines.empty())
|
||||
mSettings->userDefines += ";";
|
||||
mSettings->userDefines += define;
|
||||
|
||||
def = true;
|
||||
}
|
||||
|
@ -404,12 +404,12 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
undef = 2 + argv[i];
|
||||
}
|
||||
|
||||
_settings->userUndefs.insert(undef);
|
||||
mSettings->userUndefs.insert(undef);
|
||||
}
|
||||
|
||||
// -E
|
||||
else if (std::strcmp(argv[i], "-E") == 0) {
|
||||
_settings->preprocessOnly = true;
|
||||
mSettings->preprocessOnly = true;
|
||||
}
|
||||
|
||||
// Include paths
|
||||
|
@ -437,29 +437,29 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
if (!endsWith(path,'/'))
|
||||
path += '/';
|
||||
|
||||
_settings->includePaths.push_back(path);
|
||||
mSettings->includePaths.push_back(path);
|
||||
} else if (std::strncmp(argv[i], "--include=", 10) == 0) {
|
||||
std::string path = argv[i] + 10;
|
||||
|
||||
path = Path::fromNativeSeparators(path);
|
||||
|
||||
_settings->userIncludes.push_back(path);
|
||||
mSettings->userIncludes.push_back(path);
|
||||
} else if (std::strncmp(argv[i], "--includes-file=", 16) == 0) {
|
||||
// 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) {
|
||||
std::string path = argv[i] + 17;
|
||||
path = Path::fromNativeSeparators(path);
|
||||
_settings->configExcludePaths.insert(path);
|
||||
mSettings->configExcludePaths.insert(path);
|
||||
} else if (std::strncmp(argv[i], "--config-excludes-file=", 23) == 0) {
|
||||
// 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
|
||||
else if (std::strncmp(argv[i], "--file-list=", 12) == 0) {
|
||||
// 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
|
||||
|
@ -491,22 +491,22 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
if (!endsWith(path, '/'))
|
||||
path += '/';
|
||||
}
|
||||
_ignoredPaths.push_back(path);
|
||||
mIgnoredPaths.push_back(path);
|
||||
}
|
||||
}
|
||||
|
||||
// --library
|
||||
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;
|
||||
}
|
||||
|
||||
// --project
|
||||
else if (std::strncmp(argv[i], "--project=", 10) == 0) {
|
||||
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 (!CppCheckExecutor::tryLoadLibrary(_settings->library, argv[0], "windows.cfg")) {
|
||||
if (!CppCheckExecutor::tryLoadLibrary(mSettings->library, argv[0], "windows.cfg")) {
|
||||
// This shouldn't happen normally.
|
||||
printMessage("cppcheck: Failed to load 'windows.cfg'. Your Cppcheck installation is broken. Please re-install.");
|
||||
return false;
|
||||
|
@ -524,24 +524,24 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
// Report progress
|
||||
else if (std::strcmp(argv[i], "--report-progress") == 0) {
|
||||
_settings->reportProgress = true;
|
||||
mSettings->reportProgress = true;
|
||||
}
|
||||
|
||||
// --std
|
||||
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) {
|
||||
_settings->standards.c = Standards::C89;
|
||||
mSettings->standards.c = Standards::C89;
|
||||
} 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) {
|
||||
_settings->standards.c = Standards::C11;
|
||||
mSettings->standards.c = Standards::C11;
|
||||
} 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) {
|
||||
_settings->standards.cpp = Standards::CPP11;
|
||||
mSettings->standards.cpp = Standards::CPP11;
|
||||
} else if (std::strcmp(argv[i], "--std=c++14") == 0) {
|
||||
_settings->standards.cpp = Standards::CPP14;
|
||||
mSettings->standards.cpp = Standards::CPP14;
|
||||
}
|
||||
|
||||
// Output formatter
|
||||
|
@ -549,36 +549,36 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
std::strncmp(argv[i], "--template=", 11) == 0) {
|
||||
// "--template format"
|
||||
if (argv[i][10] == '=')
|
||||
_settings->templateFormat = argv[i] + 11;
|
||||
mSettings->templateFormat = argv[i] + 11;
|
||||
else if ((i+1) < argc && argv[i+1][0] != '-') {
|
||||
++i;
|
||||
_settings->templateFormat = argv[i];
|
||||
mSettings->templateFormat = argv[i];
|
||||
} else {
|
||||
printMessage("cppcheck: argument to '--template' is missing.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_settings->templateFormat == "gcc") {
|
||||
if (mSettings->templateFormat == "gcc") {
|
||||
//_settings->templateFormat = "{file}:{line}: {severity}: {message}";
|
||||
_settings->templateFormat = "{file}:{line}:{column}: warning: {message} [{id}]\\n{code}";
|
||||
_settings->templateLocation = "{file}:{line}:{column}: note: {info}\\n{code}";
|
||||
} else if (_settings->templateFormat == "daca2") {
|
||||
_settings->templateFormat = "{file}:{line}:{column}: {severity}: {message} [{id}]";
|
||||
_settings->templateLocation = "{file}:{line}:{column}: note: {info}";
|
||||
} else if (_settings->templateFormat == "vs")
|
||||
_settings->templateFormat = "{file}({line}): {severity}: {message}";
|
||||
else if (_settings->templateFormat == "edit")
|
||||
_settings->templateFormat = "{file} +{line}: {severity}: {message}";
|
||||
mSettings->templateFormat = "{file}:{line}:{column}: warning: {message} [{id}]\\n{code}";
|
||||
mSettings->templateLocation = "{file}:{line}:{column}: note: {info}\\n{code}";
|
||||
} else if (mSettings->templateFormat == "daca2") {
|
||||
mSettings->templateFormat = "{file}:{line}:{column}: {severity}: {message} [{id}]";
|
||||
mSettings->templateLocation = "{file}:{line}:{column}: note: {info}";
|
||||
} else if (mSettings->templateFormat == "vs")
|
||||
mSettings->templateFormat = "{file}({line}): {severity}: {message}";
|
||||
else if (mSettings->templateFormat == "edit")
|
||||
mSettings->templateFormat = "{file} +{line}: {severity}: {message}";
|
||||
}
|
||||
|
||||
else if (std::strcmp(argv[i], "--template-location") == 0 ||
|
||||
std::strncmp(argv[i], "--template-location=", 20) == 0) {
|
||||
// "--template-location format"
|
||||
if (argv[i][19] == '=')
|
||||
_settings->templateLocation = argv[i] + 20;
|
||||
mSettings->templateLocation = argv[i] + 20;
|
||||
else if ((i+1) < argc && argv[i+1][0] != '-') {
|
||||
++i;
|
||||
_settings->templateLocation = argv[i];
|
||||
mSettings->templateLocation = argv[i];
|
||||
} else {
|
||||
printMessage("cppcheck: argument to '--template' is missing.");
|
||||
return false;
|
||||
|
@ -605,12 +605,12 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
numberString = argv[i]+2;
|
||||
|
||||
std::istringstream iss(numberString);
|
||||
if (!(iss >> _settings->jobs)) {
|
||||
if (!(iss >> mSettings->jobs)) {
|
||||
printMessage("cppcheck: argument to '-j' is not a number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_settings->jobs > 10000) {
|
||||
if (mSettings->jobs > 10000) {
|
||||
// This limit is here just to catch typos. If someone has
|
||||
// need for more jobs, this value should be increased.
|
||||
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;
|
||||
|
||||
std::istringstream iss(numberString);
|
||||
if (!(iss >> _settings->loadAverage)) {
|
||||
if (!(iss >> mSettings->loadAverage)) {
|
||||
printMessage("cppcheck: argument to '-l' is not a number.");
|
||||
return false;
|
||||
}
|
||||
|
@ -643,9 +643,9 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
// print all possible error messages..
|
||||
else if (std::strcmp(argv[i], "--errorlist") == 0) {
|
||||
_showErrorMessages = true;
|
||||
_settings->xml = true;
|
||||
_exitAfterPrint = true;
|
||||
mShowErrorMessages = true;
|
||||
mSettings->xml = true;
|
||||
mExitAfterPrint = true;
|
||||
}
|
||||
|
||||
// documentation..
|
||||
|
@ -661,7 +661,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
}
|
||||
|
||||
std::cout << doc.str();
|
||||
_exitAfterPrint = true;
|
||||
mExitAfterPrint = 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) {
|
||||
const std::string showtimeMode = argv[i] + 11;
|
||||
if (showtimeMode == "file")
|
||||
_settings->showtime = SHOWTIME_FILE;
|
||||
mSettings->showtime = SHOWTIME_FILE;
|
||||
else if (showtimeMode == "summary")
|
||||
_settings->showtime = SHOWTIME_SUMMARY;
|
||||
mSettings->showtime = SHOWTIME_SUMMARY;
|
||||
else if (showtimeMode == "top5")
|
||||
_settings->showtime = SHOWTIME_TOP5;
|
||||
mSettings->showtime = SHOWTIME_TOP5;
|
||||
else if (showtimeMode.empty())
|
||||
_settings->showtime = SHOWTIME_NONE;
|
||||
mSettings->showtime = SHOWTIME_NONE;
|
||||
else {
|
||||
std::string message("cppcheck: error: unrecognized showtime mode: \"");
|
||||
message += showtimeMode;
|
||||
|
@ -690,7 +690,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
else if (std::strncmp(argv[i], "--rule=", 7) == 0) {
|
||||
Settings::Rule rule;
|
||||
rule.pattern = 7 + argv[i];
|
||||
_settings->rules.push_back(rule);
|
||||
mSettings->rules.push_back(rule);
|
||||
}
|
||||
|
||||
// Rule file
|
||||
|
@ -726,7 +726,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
}
|
||||
|
||||
if (!rule.pattern.empty())
|
||||
_settings->rules.push_back(rule);
|
||||
mSettings->rules.push_back(rule);
|
||||
}
|
||||
} else {
|
||||
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]);
|
||||
|
||||
if (platform == "win32A")
|
||||
_settings->platform(Settings::Win32A);
|
||||
mSettings->platform(Settings::Win32A);
|
||||
else if (platform == "win32W")
|
||||
_settings->platform(Settings::Win32W);
|
||||
mSettings->platform(Settings::Win32W);
|
||||
else if (platform == "win64")
|
||||
_settings->platform(Settings::Win64);
|
||||
mSettings->platform(Settings::Win64);
|
||||
else if (platform == "unix32")
|
||||
_settings->platform(Settings::Unix32);
|
||||
mSettings->platform(Settings::Unix32);
|
||||
else if (platform == "unix64")
|
||||
_settings->platform(Settings::Unix64);
|
||||
mSettings->platform(Settings::Unix64);
|
||||
else if (platform == "native")
|
||||
_settings->platform(Settings::Native);
|
||||
mSettings->platform(Settings::Native);
|
||||
else if (platform == "unspecified")
|
||||
_settings->platform(Settings::Unspecified);
|
||||
else if (!_settings->loadPlatformFile(argv[0], platform)) {
|
||||
mSettings->platform(Settings::Unspecified);
|
||||
else if (!mSettings->loadPlatformFile(argv[0], platform)) {
|
||||
std::string message("cppcheck: error: unrecognized platform: \"");
|
||||
message += platform;
|
||||
message += "\".";
|
||||
|
@ -764,15 +764,15 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
// Set maximum number of #ifdef configurations to check
|
||||
else if (std::strncmp(argv[i], "--max-configs=", 14) == 0) {
|
||||
_settings->force = false;
|
||||
mSettings->force = false;
|
||||
|
||||
std::istringstream iss(14+argv[i]);
|
||||
if (!(iss >> _settings->maxConfigs)) {
|
||||
if (!(iss >> mSettings->maxConfigs)) {
|
||||
printMessage("cppcheck: argument to '--max-configs=' is not a number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_settings->maxConfigs < 1) {
|
||||
if (mSettings->maxConfigs < 1) {
|
||||
printMessage("cppcheck: argument to '--max-configs=' must be greater than 0.");
|
||||
return false;
|
||||
}
|
||||
|
@ -782,9 +782,9 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
// Print help
|
||||
else if (std::strcmp(argv[i], "-h") == 0 || std::strcmp(argv[i], "--help") == 0) {
|
||||
_pathnames.clear();
|
||||
_showHelp = true;
|
||||
_exitAfterPrint = true;
|
||||
mPathNames.clear();
|
||||
mShowHelp = true;
|
||||
mExitAfterPrint = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -800,41 +800,41 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
else {
|
||||
std::string path = Path::removeQuotationMarks(argv[i]);
|
||||
path = Path::fromNativeSeparators(path);
|
||||
_pathnames.push_back(path);
|
||||
mPathNames.push_back(path);
|
||||
}
|
||||
}
|
||||
|
||||
_settings->project.ignorePaths(_ignoredPaths);
|
||||
mSettings->project.ignorePaths(mIgnoredPaths);
|
||||
|
||||
if (_settings->force)
|
||||
_settings->maxConfigs = ~0U;
|
||||
if (mSettings->force)
|
||||
mSettings->maxConfigs = ~0U;
|
||||
|
||||
else if ((def || _settings->preprocessOnly) && !maxconfigs)
|
||||
_settings->maxConfigs = 1U;
|
||||
else if ((def || mSettings->preprocessOnly) && !maxconfigs)
|
||||
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.");
|
||||
}
|
||||
|
||||
if (argc <= 1) {
|
||||
_showHelp = true;
|
||||
_exitAfterPrint = true;
|
||||
mShowHelp = true;
|
||||
mExitAfterPrint = true;
|
||||
}
|
||||
|
||||
if (_showHelp) {
|
||||
if (mShowHelp) {
|
||||
printHelp();
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Use paths _pathnames if no base paths for relative path output are given
|
||||
if (_settings->basePaths.empty() && _settings->relativePaths)
|
||||
_settings->basePaths = _pathnames;
|
||||
if (mSettings->basePaths.empty() && mSettings->relativePaths)
|
||||
mSettings->basePaths = mPathNames;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -55,42 +55,42 @@ public:
|
|||
* Return if user wanted to see program version.
|
||||
*/
|
||||
bool getShowVersion() const {
|
||||
return _showVersion;
|
||||
return mShowVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if user wanted to see list of error messages.
|
||||
*/
|
||||
bool getShowErrorMessages() const {
|
||||
return _showErrorMessages;
|
||||
return mShowErrorMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path names user gave to command line.
|
||||
*/
|
||||
const std::vector<std::string>& getPathNames() const {
|
||||
return _pathnames;
|
||||
return mPathNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if help is shown to user.
|
||||
*/
|
||||
bool getShowHelp() const {
|
||||
return _showHelp;
|
||||
return mShowHelp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if we should exit after printing version, help etc.
|
||||
*/
|
||||
bool exitAfterPrinting() const {
|
||||
return _exitAfterPrint;
|
||||
return mExitAfterPrint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of paths user wants to ignore.
|
||||
*/
|
||||
const std::vector<std::string>& getIgnoredPaths() const {
|
||||
return _ignoredPaths;
|
||||
return mIgnoredPaths;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -107,13 +107,13 @@ protected:
|
|||
static void printMessage(const char* message);
|
||||
|
||||
private:
|
||||
std::vector<std::string> _pathnames;
|
||||
std::vector<std::string> _ignoredPaths;
|
||||
Settings *_settings;
|
||||
bool _showHelp;
|
||||
bool _showVersion;
|
||||
bool _showErrorMessages;
|
||||
bool _exitAfterPrint;
|
||||
std::vector<std::string> mPathNames;
|
||||
std::vector<std::string> mIgnoredPaths;
|
||||
Settings *mSettings;
|
||||
bool mShowHelp;
|
||||
bool mShowVersion;
|
||||
bool mShowErrorMessages;
|
||||
bool mExitAfterPrint;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
|
Loading…
Reference in New Issue