Fix ticket #89 (False positive, (style) Redundant code - begins with numeric constant (e-value))

This commit is contained in:
Reijo Tomperi 2009-02-08 10:39:55 +00:00
parent da3efe8fa2
commit c345fa6186
2 changed files with 4 additions and 2 deletions

View File

@ -322,7 +322,7 @@ void Tokenizer::tokenize(std::istream &code, const char FileName[])
if (strchr("#+-*/%&|^?!=<>[](){};:,.~", ch))
{
if (ch == '.' && std::isdigit(CurrentToken[0]))
if (strchr(".+-", ch) && std::isdigit(CurrentToken[0]))
{
// Don't separate doubles
}

View File

@ -997,6 +997,8 @@ private:
"{\n"
" double a = 4.2;\n"
" float b = 4.2f;\n"
" double c = 4.2e+10;\n"
" double d = 4.2e-10;\n"
"}\n";
// tokenize..
@ -1007,7 +1009,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { double a = 4.2 ; float b = 4.2f ; }"), ostr.str());
ASSERT_EQUALS(std::string(" void f ( ) { double a = 4.2 ; float b = 4.2f ; double c = 4.2e+10 ; double d = 4.2e-10 ; }"), ostr.str());
}
void tokenize_strings()