cmdlineparser: allow space between -D and define name. ticket: #2036

This commit is contained in:
Daniel Marjamäki 2010-09-08 17:42:28 +02:00
parent 3c8ffb90dd
commit ad03c97a6e
2 changed files with 15 additions and 1 deletions

View File

@ -182,6 +182,9 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
{
if (!_settings->userDefines.empty())
_settings->userDefines += ";";
if (strcmp(argv[i], "-D") == 0)
_settings->userDefines += argv[++i];
else
_settings->userDefines += 2 + argv[i];
}

View File

@ -85,6 +85,7 @@ private:
TEST_CASE(quietlong);
TEST_CASE(defines);
TEST_CASE(defines2);
TEST_CASE(defines3);
TEST_CASE(includesnopath);
TEST_CASE(includes);
TEST_CASE(includes2);
@ -262,6 +263,16 @@ private:
ASSERT_EQUALS("_WIN32;NODEBUG", settings.userDefines);
}
void defines3()
{
REDIRECT;
const char *argv[] = {"cppcheck", "-D", "DEBUG", "file.cpp"};
Settings settings;
CmdLineParser parser(&settings);
ASSERT(parser.ParseFromArgs(4, argv));
ASSERT_EQUALS("DEBUG", settings.userDefines);
}
void includesnopath()
{
REDIRECT;