From 40f3ef61c9e551bece9c5e610461b32a03a9e34f Mon Sep 17 00:00:00 2001 From: Nicolas Le Cam Date: Mon, 15 Dec 2008 23:03:04 +0000 Subject: [PATCH] Removes WarningIs(Alpha|Digit) checks as this can introduce more problems than fixes. --- checkother.cpp | 83 -------------------------------------------------- checkother.h | 6 ---- cppcheck.cpp | 4 --- 3 files changed, 93 deletions(-) diff --git a/checkother.cpp b/checkother.cpp index 1d417b06e..2d36313f7 100644 --- a/checkother.cpp +++ b/checkother.cpp @@ -69,89 +69,6 @@ void CheckOther::WarningOldStylePointerCast() -//--------------------------------------------------------------------------- -// Use standard function "isdigit" instead -//--------------------------------------------------------------------------- - -void CheckOther::WarningIsDigit() -{ - for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next()) - { - bool err = false; - err |= TOKEN::Match(tok, "%var% >= '0' && %var% <= '9'"); - err |= TOKEN::Match(tok, "* %var% >= '0' && * %var% <= '9'"); - err |= TOKEN::Match(tok, "( %var% >= '0' ) && ( %var% <= '9' )"); - err |= TOKEN::Match(tok, "( * %var% >= '0' ) && ( * %var% <= '9' )"); - if (err) - { - std::ostringstream ostr; - ostr << _tokenizer->fileLine(tok) << ": The condition can be simplified; use 'isdigit'"; - _errorLogger->reportErr(ostr.str()); - } - } -} -//--------------------------------------------------------------------------- - - - -//--------------------------------------------------------------------------- -// Use standard function "isalpha" instead -//--------------------------------------------------------------------------- - -void CheckOther::WarningIsAlpha() -{ - for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next()) - { - if ( tok->str() != "(" ) - continue; - - bool err = false; - - err |= TOKEN::Match(tok, "( %var% >= 'A' && %var% <= 'Z' )"); - err |= TOKEN::Match(tok, "( * %var% >= 'A' && * %var% <= 'Z' )"); - err |= TOKEN::Match(tok, "( ( %var% >= 'A' ) && ( %var% <= 'Z' ) )"); - err |= TOKEN::Match(tok, "( ( * %var% >= 'A' ) && ( * %var% <= 'Z' ) )"); - if (err) - { - std::ostringstream ostr; - ostr << _tokenizer->fileLine(tok) << ": The condition can be simplified; use 'isupper'"; - _errorLogger->reportErr(ostr.str()); - continue; - } - - err = false; - err |= TOKEN::Match(tok, "( %var% >= 'a' && %var% <= 'z' )"); - err |= TOKEN::Match(tok, "( * %var% >= 'a' && * %var% <= 'z' )"); - err |= TOKEN::Match(tok, "( ( %var% >= 'a' ) && ( %var% <= 'z' ) )"); - err |= TOKEN::Match(tok, "( ( * %var% >= 'a' ) && ( * %var% <= 'z' ) )"); - if (err) - { - std::ostringstream ostr; - ostr << _tokenizer->fileLine(tok) << ": The condition can be simplified; use 'islower'"; - _errorLogger->reportErr(ostr.str()); - continue; - } - - err = false; - err |= TOKEN::Match(tok, "( %var% >= 'A' && %var% <= 'Z' ) || ( %var% >= 'a' && %var% <= 'z' )"); - err |= TOKEN::Match(tok, "( %var% >= 'a' && %var% <= 'z' ) || ( %var% >= 'A' && %var% <= 'Z' )"); - err |= TOKEN::Match(tok, "( * %var% >= 'A' && * %var% <= 'Z' ) || ( * %var% >= 'a' && * %var% <= 'z' )"); - err |= TOKEN::Match(tok, "( * %var% >= 'a' && * %var% <= 'z' ) || ( * %var% >= 'A' && * %var% <= 'Z' )"); - err |= TOKEN::Match(tok, "( ( %var% >= 'A' ) && ( %var% <= 'Z' ) ) || ( ( %var% >= 'a' ) && ( %var% <= 'z' ) )"); - err |= TOKEN::Match(tok, "( ( %var% >= 'a' ) && ( %var% <= 'z' ) ) || ( ( %var% >= 'A' ) && ( %var% <= 'Z' ) )"); - err |= TOKEN::Match(tok, "( ( * %var% >= 'A' ) && ( * %var% <= 'Z' ) ) || ( ( * var >= 'a' ) && ( * %var% <= 'z' ) )"); - err |= TOKEN::Match(tok, "( ( * %var% >= 'a' ) && ( * %var% <= 'z' ) ) || ( ( * var >= 'A' ) && ( * %var% <= 'Z' ) )"); - if (err) - { - std::ostringstream ostr; - ostr << _tokenizer->fileLine(tok) << ": The condition can be simplified; use 'isalpha'"; - _errorLogger->reportErr(ostr.str()); - } - } -} -//--------------------------------------------------------------------------- - - //--------------------------------------------------------------------------- // Redundant code.. //--------------------------------------------------------------------------- diff --git a/checkother.h b/checkother.h index a84cd424c..c7f8ec025 100644 --- a/checkother.h +++ b/checkother.h @@ -35,12 +35,6 @@ public: // Casting void WarningOldStylePointerCast(); - // Use standard functions instead - void WarningIsDigit(); - - // Use standard functions instead - void WarningIsAlpha(); - // Redundant code void WarningRedundantCode(); diff --git a/cppcheck.cpp b/cppcheck.cpp index d520fbab3..e29b065c3 100644 --- a/cppcheck.cpp +++ b/cppcheck.cpp @@ -302,10 +302,6 @@ void CppCheck::checkFile(const std::string &code, const char FileName[]) if (ext && strcmp(ext,".cpp")==0) checkOther.WarningOldStylePointerCast(); - // Use standard functions instead - checkOther.WarningIsDigit(); - checkOther.WarningIsAlpha(); - checkClass.CheckOperatorEq1(); // if (a) delete a;