Preprocessor: make sure 1e-7 is output as a single token. puttin a macroChar before the 7 mess it up later.

This commit is contained in:
Daniel Marjamäki 2013-12-29 21:51:01 +01:00
parent c56a432e2d
commit 582baa5648
2 changed files with 14 additions and 0 deletions

View File

@ -3158,6 +3158,13 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file
(macrocode[i-1] != macroChar)) {
macrocode.insert(i, 1U, macroChar);
}
// 1e-7
if (i+3 < macrocode.size() &&
std::isdigit(macrocode[i]) &&
macrocode[i+1] == 'e' &&
macrocode[i+2] == '-' &&
std::isdigit(macrocode[i+3]))
i += 3;
}
}
line.insert(pos1, macroChar + macrocode);

View File

@ -183,6 +183,7 @@ private:
TEST_CASE(macro_simple15);
TEST_CASE(macro_simple16); // #4703: Macro parameters not trimmed
TEST_CASE(macro_simple17); // #5074: isExpandedMacro not set
TEST_CASE(macro_simple18); // (1e-7)
TEST_CASE(macroInMacro1);
TEST_CASE(macroInMacro2);
TEST_CASE(macro_mismatch);
@ -1977,6 +1978,12 @@ private:
ASSERT_EQUALS("\n$123+$123", OurPreprocessor::expandMacros(filedata));
}
void macro_simple18() { // (1e-7)
const char filedata[] = "#define A (1e-7)\n"
"a=A;";
ASSERT_EQUALS("\na=$($1e-7);", OurPreprocessor::expandMacros(filedata));
}
void macroInMacro1() {
{
const char filedata[] = "#define A(m) long n = m; n++;\n"