diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 11ce70a25..63a775397 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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" diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7ba167e08..0f6fb18d1 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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("");