Fixed #2429 (Tokenizer: Wrong simplification of 'sizeof .1250E+04')
This commit is contained in:
parent
d316f6005f
commit
88abb32ddf
|
@ -361,6 +361,11 @@ void Tokenizer::createTokens(std::istream &code)
|
||||||
{
|
{
|
||||||
// Don't separate doubles "4.2e+10"
|
// 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() == '&')
|
else if (ch=='&' && CurrentToken.empty() && code.peek() == '&')
|
||||||
{
|
{
|
||||||
// &&
|
// &&
|
||||||
|
|
|
@ -52,6 +52,7 @@ private:
|
||||||
TEST_CASE(tokenize12);
|
TEST_CASE(tokenize12);
|
||||||
TEST_CASE(tokenize13); // bailout if the code contains "@" - that is not handled well.
|
TEST_CASE(tokenize13); // bailout if the code contains "@" - that is not handled well.
|
||||||
TEST_CASE(tokenize14); // tokenize "0X10" => 16
|
TEST_CASE(tokenize14); // tokenize "0X10" => 16
|
||||||
|
TEST_CASE(tokenize15); // tokenize ".123"
|
||||||
|
|
||||||
// don't freak out when the syntax is wrong
|
// don't freak out when the syntax is wrong
|
||||||
TEST_CASE(wrong_syntax);
|
TEST_CASE(wrong_syntax);
|
||||||
|
@ -490,6 +491,12 @@ private:
|
||||||
ASSERT_EQUALS("; 16 ;", tokenizeAndStringify(";0x10;"));
|
ASSERT_EQUALS("; 16 ;", tokenizeAndStringify(";0x10;"));
|
||||||
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()
|
void wrong_syntax()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue