Tokenizer: The tokenizer didn't handle '0x0E-7' correctly

This commit is contained in:
Daniel Marjamäki 2011-12-18 07:37:20 +01:00
parent 5f712cc213
commit 83cdf734fe
2 changed files with 6 additions and 0 deletions

View File

@ -358,6 +358,7 @@ void Tokenizer::createTokens(std::istream &code)
} else if (strchr("+-", ch) &&
CurrentToken.length() > 0 &&
std::isdigit(CurrentToken[0]) &&
CurrentToken.compare(0,2,"0x") != 0 &&
(CurrentToken[CurrentToken.length()-1] == 'e' ||
CurrentToken[CurrentToken.length()-1] == 'E')) {
// Don't separate doubles "4.2e+10"

View File

@ -52,6 +52,7 @@ private:
TEST_CASE(tokenize18); // tokenize "(X&&Y)" into "( X && Y )" instead of "( X & & Y )"
TEST_CASE(tokenize19); // #3006 (segmentation fault)
TEST_CASE(tokenize20); // replace C99 _Bool => bool
TEST_CASE(tokenize21); // tokenize 0x0E-7
// don't freak out when the syntax is wrong
TEST_CASE(wrong_syntax);
@ -601,6 +602,10 @@ private:
ASSERT_EQUALS("bool a ; a = true ;", tokenizeAndStringify("_Bool a = true;"));
}
void tokenize21() { // tokenize 0x0E-7
ASSERT_EQUALS("14 - 7", tokenizeAndStringify("0x0E-7"));
}
void wrong_syntax() {
{
errout.str("");