Command line: Added --std option. Right now only --std=posix is possible but other options might be added later.

This commit is contained in:
Daniel Marjamäki 2011-08-17 20:08:55 +02:00
parent aecf9fadcd
commit afed93d7d6
3 changed files with 20 additions and 1 deletions

View File

@ -409,6 +409,12 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
_settings->reportProgress = true; _settings->reportProgress = true;
} }
// --std
else if (strcmp(argv[i], "--std=posix") == 0)
{
_settings->posix = true;
}
// Output formatter // Output formatter
else if (strcmp(argv[i], "--template") == 0) else if (strcmp(argv[i], "--template") == 0)
{ {
@ -700,6 +706,8 @@ void CmdLineParser::PrintHelp()
" https://sourceforge.net/projects/cppcheck/files/Articles/\n" " https://sourceforge.net/projects/cppcheck/files/Articles/\n"
#endif #endif
" -s, --style Deprecated, use --enable=style\n" " -s, --style Deprecated, use --enable=style\n"
" --std=posix Code is posix => it is not compatible with non-posix\n"
" environments.\n"
" --suppress=<spec> Suppress warnings that match <spec>. The format of\n" " --suppress=<spec> Suppress warnings that match <spec>. The format of\n"
" <spec> is:\n" " <spec> is:\n"
" [error id]:[filename]:[line]\n" " [error id]:[filename]:[line]\n"

View File

@ -304,7 +304,7 @@ public:
/** Is the 'configuration checking' wanted? */ /** Is the 'configuration checking' wanted? */
bool checkConfiguration; bool checkConfiguration;
/** Posix checks */ /** Code is posix - it is not compatible with non-posix environments */
bool posix; bool posix;
}; };

View File

@ -74,6 +74,7 @@ private:
TEST_CASE(jobsMissingCount); TEST_CASE(jobsMissingCount);
TEST_CASE(jobsInvalid); TEST_CASE(jobsInvalid);
TEST_CASE(reportProgress); TEST_CASE(reportProgress);
TEST_CASE(stdposix);
TEST_CASE(suppressionsOld); // TODO: Create and test real suppression file TEST_CASE(suppressionsOld); // TODO: Create and test real suppression file
TEST_CASE(suppressions); TEST_CASE(suppressions);
TEST_CASE(suppressionsNoFile); TEST_CASE(suppressionsNoFile);
@ -543,6 +544,16 @@ private:
ASSERT(settings.reportProgress); 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() void suppressionsOld()
{ {
// TODO: Fails because there is no suppr.txt file! // TODO: Fails because there is no suppr.txt file!