Fixed #2429 (Tokenizer: Wrong simplification of 'sizeof .1250E+04')

This commit is contained in:
Daniel Marjamäki 2011-01-09 10:09:54 +01:00
parent d316f6005f
commit 88abb32ddf
2 changed files with 12 additions and 0 deletions

View File

@ -361,6 +361,11 @@ void Tokenizer::createTokens(std::istream &code)
{
// Don't separate doubles "4.2e+10"
}
else if (CurrentToken.empty() && ch == '.' && std::isdigit(code.peek()))
{
// tokenize .125 into 0.125
CurrentToken = "0";
}
else if (ch=='&' && CurrentToken.empty() && code.peek() == '&')
{
// &&

View File

@ -52,6 +52,7 @@ private:
TEST_CASE(tokenize12);
TEST_CASE(tokenize13); // bailout if the code contains "@" - that is not handled well.
TEST_CASE(tokenize14); // tokenize "0X10" => 16
TEST_CASE(tokenize15); // tokenize ".123"
// don't freak out when the syntax is wrong
TEST_CASE(wrong_syntax);
@ -490,6 +491,12 @@ private:
ASSERT_EQUALS("; 16 ;", tokenizeAndStringify(";0x10;"));
ASSERT_EQUALS("; 16 ;", tokenizeAndStringify(";0X10;"));
}
// Ticket #2429: 0.125
void tokenize15()
{
ASSERT_EQUALS("0.125", tokenizeAndStringify(".125"));
}
void wrong_syntax()
{