diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index a2289d272..01dc7d7e8 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -3158,13 +3158,29 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file (macrocode[i-1] != macroChar)) { macrocode.insert(i, 1U, macroChar); } + // 1e-7 / 1e+7 - if (i+3 < macrocode.size() && - std::isdigit(macrocode[i]) && + if (i+3U < macrocode.size() && + (std::isdigit(macrocode[i]) || macrocode[i]=='.') && (macrocode[i+1] == 'e' || macrocode[i+1] == 'E') && (macrocode[i+2] == '-' || macrocode[i+2] == '+') && - std::isdigit(macrocode[i+3])) - i += 3; + std::isdigit(macrocode[i+3])) { + i += 3U; + } + + // 1.f / 1.e7 + if (i+2U < macrocode.size() && + std::isdigit(macrocode[i]) && + macrocode[i+1] == '.' && + std::isalnum(macrocode[i+2])) { + i += 2U; + if (i+2U < macrocode.size() && + (macrocode[i+0] == 'e' || macrocode[i+0] == 'E') && + (macrocode[i+1] == '-' || macrocode[i+1] == '+') && + std::isdigit(macrocode[i+2])) { + i += 2U; + } + } } } line.insert(pos1, macroChar + macrocode); diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index b436ff02d..961075675 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -1990,6 +1990,14 @@ private: const char filedata3[] = "#define A (1e+7)\n" "a=A;"; ASSERT_EQUALS("\na=$($1e+7);", OurPreprocessor::expandMacros(filedata3)); + + const char filedata4[] = "#define A (1.e+7)\n" + "a=A;"; + ASSERT_EQUALS("\na=$($1.e+7);", OurPreprocessor::expandMacros(filedata4)); + + const char filedata5[] = "#define A (1.7f)\n" + "a=A;"; + ASSERT_EQUALS("\na=$($1.7f);", OurPreprocessor::expandMacros(filedata5)); } void macroInMacro1() {