From 76dda36b6432e38c6d6701cac410a8cc07b07f19 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Thu, 10 Nov 2011 20:47:49 +0100 Subject: [PATCH] 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 --- cli/cmdlineparser.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 80591a57c..3ab627bce 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -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")