Fix #670 (Tokenizer: Simplify '\0' into 0)

http://sourceforge.net/apps/trac/cppcheck/ticket/670
This commit is contained in:
Reijo Tomperi 2009-09-14 21:42:56 +03:00
parent e3119235e0
commit 2b6955dde5
2 changed files with 4 additions and 1 deletions

View File

@ -1642,7 +1642,8 @@ void Tokenizer::simplifyTokenList()
// Replace NULL with 0..
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (tok->str() == "NULL")
if (tok->str() == "NULL" ||
tok->str() == "'\\0'")
tok->str("0");
}

View File

@ -376,6 +376,7 @@ private:
" while (NULL == Foo::p);\n"
" if (p1 != NULL || p2 == NULL) { ; }\n"
" if (p1 != NULL && p2 == NULL) { ; }\n"
" if (p == '\\0');\n"
"}\n";
ASSERT_EQUALS("void f ( )\n"
@ -406,6 +407,7 @@ private:
"while ( ! Foo :: p ) { ; }\n"
"if ( p1 || ! p2 ) { ; }\n"
"if ( p1 && ! p2 ) { ; }\n"
"if ( ! p ) { ; }\n"
"}", tokenizeAndStringify(code, true));
}