CLI: Rename --posix to --enable=posix.

Ticket: #2949 (new check: (style) finding non-reentrant functions)
Ticket: #2952 (CLI option --posix is wrong)
This commit is contained in:
Kimmo Varis 2011-08-03 10:28:36 +03:00
parent 6755d4befb
commit f4950ea836
6 changed files with 17 additions and 25 deletions

View File

@ -460,13 +460,6 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
}
}
// Posix compliant code checks
else if (strcmp(argv[i], "--posix") == 0)
{
_settings->_posix = true;
}
// deprecated: auto deallocated classes..
else if (strcmp(argv[i], "--auto-dealloc") == 0)
{
@ -662,6 +655,9 @@ void CmdLineParser::PrintHelp()
" * missingInclude\n"
" Warn if there are missing includes.\n"
" For detailed information use --check-config\n"
" * posix\n"
" Enable checks specific for POSIX-compiliant\n"
" code.\n"
" Several ids can be given if you separate them with\n"
" commas.\n"
" --error-exitcode=<n> If errors are found, integer [n] is returned instead\n"
@ -689,7 +685,6 @@ void CmdLineParser::PrintHelp()
" more comments, like: // cppcheck-suppress warningId\n"
" on the lines before the warning to suppress.\n"
" -j <jobs> Start [jobs] threads to do the checking simultaneously.\n"
" --posix Enable checks applicable only to Posix compliant code.\n"
" -q, --quiet Only print error messages.\n"
" --report-progress Report progress messages while checking a file.\n"
#ifdef HAVE_RULES

View File

@ -33,7 +33,7 @@ CheckNonReentrantFunctions instance;
void CheckNonReentrantFunctions::nonReentrantFunctions()
{
if (!_settings->_posix || !_settings->_checkCodingStyle)
if (!_settings->isEnabled("posix") || !_settings->_checkCodingStyle)
return;
// Don't check C# and Java code

View File

@ -36,7 +36,6 @@ Settings::Settings()
_inlineSuppressions = false;
_verbose = false;
_force = false;
_posix = false;
_xml = false;
_xml_version = 1;
_jobs = 1;
@ -399,6 +398,7 @@ std::string Settings::addEnabled(const std::string &str)
id.insert("missingInclude");
id.insert("unusedFunction");
id.insert("information");
id.insert("posix");
if (str == "all")
{

View File

@ -96,9 +96,6 @@ public:
/** @brief write XML results (--xml) */
bool _xml;
/** @brief check posix functions (--posix) */
bool _posix;
/** @brief XML version (--xmlver=..) */
int _xml_version;

View File

@ -62,6 +62,7 @@ private:
TEST_CASE(enabledStyle);
TEST_CASE(enabledUnusedFunction);
TEST_CASE(enabledMissingInclude);
TEST_CASE(enablePosix);
TEST_CASE(errorExitcode);
TEST_CASE(errorExitcodeMissing);
TEST_CASE(errorExitcodeStr);
@ -100,7 +101,6 @@ private:
TEST_CASE(ignorefilepaths1);
TEST_CASE(ignorefilepaths2);
TEST_CASE(checkconfig);
TEST_CASE(posix);
TEST_CASE(unknownParam);
}
@ -421,6 +421,16 @@ private:
ASSERT(settings.isEnabled("missingInclude"));
}
void enablePosix()
{
REDIRECT;
const char *argv[] = {"cppcheck", "--enable=posix", "file.cpp"};
Settings settings;
CmdLineParser parser(&settings);
ASSERT(parser.ParseFromArgs(3, argv));
ASSERT(settings.isEnabled("posix"));
}
void errorExitcode()
{
REDIRECT;
@ -813,16 +823,6 @@ private:
ASSERT_EQUALS(true, settings.checkConfiguration);
}
void posix()
{
REDIRECT;
const char *argv[] = {"cppcheck", "--posix", "file.cpp"};
Settings settings;
CmdLineParser parser(&settings);
ASSERT(parser.ParseFromArgs(3, argv));
ASSERT_EQUALS(true, settings._posix);
}
void unknownParam()
{
REDIRECT;

View File

@ -45,7 +45,7 @@ private:
errout.str("");
Settings settings;
settings._posix = true;
settings.addEnabled("posix");
settings.inconclusive = true;
settings._checkCodingStyle = true;