cmdlineparser: add support for --template=

The GNU standard for long command line options is --option=value.
All other long options of cppcheck support this, so add it for
the template option, too.

--template xxx can be made obsolete later.

Should the documentation and tests also be changed now?

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2011-11-10 20:47:49 +01:00 committed by Reijo Tomperi
parent 93b1bba8cb
commit 76dda36b64
1 changed files with 9 additions and 4 deletions

View File

@ -410,15 +410,20 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
}
// Output formatter
else if (strcmp(argv[i], "--template") == 0) {
else if (strcmp(argv[i], "--template") == 0 ||
strncmp(argv[i], "--template=", 11) == 0) {
// "--template path/"
++i;
if (i >= argc) {
if (argv[i][10] == '=')
_settings->_outputFormat = argv[i] + 11;
else {
++i;
_settings->_outputFormat = (argv[i] ? argv[i] : "");
}
if (_settings->_outputFormat.empty()) {
PrintMessage("cppcheck: argument to '--template' is missing.");
return false;
}
_settings->_outputFormat = argv[i];
if (_settings->_outputFormat == "gcc")
_settings->_outputFormat = "{file}:{line}: {severity}: {message}";
else if (_settings->_outputFormat == "vs")