Fixed #2361 (false positive on t[0X10])

This commit is contained in:
Daniel Marjamäki 2010-12-27 08:09:05 +01:00
parent 0758160fcd
commit 2367cfcf1e
2 changed files with 9 additions and 1 deletions

View File

@ -126,7 +126,7 @@ void Tokenizer::addtoken(const char str[], const unsigned int lineno, const unsi
// Replace hexadecimal value with decimal
std::ostringstream str2;
if (strncmp(str, "0x", 2) == 0)
if (strncmp(str, "0x", 2) == 0 || strncmp(str, "0X", 2) == 0)
{
str2 << std::strtoul(str + 2, NULL, 16);
}

View File

@ -51,6 +51,7 @@ private:
TEST_CASE(tokenize11);
TEST_CASE(tokenize12);
TEST_CASE(tokenize13); // bailout if the code contains "@" - that is not handled well.
TEST_CASE(tokenize14); // tokenize "0X10" => 16
// don't freak out when the syntax is wrong
TEST_CASE(wrong_syntax);
@ -481,6 +482,13 @@ private:
ASSERT_EQUALS("", tokenizeAndStringify(code));
}
// Ticket #2361: 0X10 => 16
void tokenize14()
{
ASSERT_EQUALS("; 16 ;", tokenizeAndStringify(";0x10;"));
ASSERT_EQUALS("; 16 ;", tokenizeAndStringify(";0X10;"));
}
void wrong_syntax()
{
{