Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Command line: Added --std option. Right now only --std=posix is possi…
…ble but other options might be added later.
  • Loading branch information
Daniel Marjamäki committed Aug 17, 2011
1 parent aecf9fa commit afed93d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cli/cmdlineparser.cpp
Expand Up @@ -409,6 +409,12 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
_settings->reportProgress = true;
}

// --std
else if (strcmp(argv[i], "--std=posix") == 0)
{
_settings->posix = true;
}

// Output formatter
else if (strcmp(argv[i], "--template") == 0)
{
Expand Down Expand Up @@ -700,6 +706,8 @@ void CmdLineParser::PrintHelp()
" https://sourceforge.net/projects/cppcheck/files/Articles/\n"
#endif
" -s, --style Deprecated, use --enable=style\n"
" --std=posix Code is posix => it is not compatible with non-posix\n"

This comment has been minimized.

Copy link
@kimmov

kimmov Aug 17, 2011

Contributor

Needs a better description for sure.

" environments.\n"
" --suppress=<spec> Suppress warnings that match <spec>. The format of\n"
" <spec> is:\n"
" [error id]:[filename]:[line]\n"
Expand Down
2 changes: 1 addition & 1 deletion lib/settings.h
Expand Up @@ -304,7 +304,7 @@ class Settings
/** Is the 'configuration checking' wanted? */
bool checkConfiguration;

/** Posix checks */
/** Code is posix - it is not compatible with non-posix environments */
bool posix;
};

Expand Down
11 changes: 11 additions & 0 deletions test/testcmdlineparser.cpp
Expand Up @@ -74,6 +74,7 @@ class TestCmdlineParser : public TestFixture
TEST_CASE(jobsMissingCount);
TEST_CASE(jobsInvalid);
TEST_CASE(reportProgress);
TEST_CASE(stdposix);
TEST_CASE(suppressionsOld); // TODO: Create and test real suppression file
TEST_CASE(suppressions);
TEST_CASE(suppressionsNoFile);
Expand Down Expand Up @@ -543,6 +544,16 @@ class TestCmdlineParser : public TestFixture
ASSERT(settings.reportProgress);
}

void stdposix()
{
REDIRECT;
const char *argv[] = {"cppcheck", "--std=posix", "file.cpp"};
Settings settings;
CmdLineParser parser(&settings);
ASSERT(parser.ParseFromArgs(3, argv));
ASSERT(settings.posix);
}

void suppressionsOld()
{
// TODO: Fails because there is no suppr.txt file!
Expand Down

0 comments on commit afed93d

Please sign in to comment.