Preprocessor: make sure 1E-7, 1E+7, 1e+7 in macros is output as a single token. Putting a macroChar before the 7 mess it up later.
This commit is contained in:
parent
4f0121ee2f
commit
99703e1a3f
|
@ -3158,11 +3158,11 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file
|
||||||
(macrocode[i-1] != macroChar)) {
|
(macrocode[i-1] != macroChar)) {
|
||||||
macrocode.insert(i, 1U, macroChar);
|
macrocode.insert(i, 1U, macroChar);
|
||||||
}
|
}
|
||||||
// 1e-7
|
// 1e-7 / 1e+7
|
||||||
if (i+3 < macrocode.size() &&
|
if (i+3 < macrocode.size() &&
|
||||||
std::isdigit(macrocode[i]) &&
|
std::isdigit(macrocode[i]) &&
|
||||||
macrocode[i+1] == 'e' &&
|
(macrocode[i+1] == 'e' || macrocode[i+1] == 'E') &&
|
||||||
macrocode[i+2] == '-' &&
|
(macrocode[i+2] == '-' || macrocode[i+2] == '+') &&
|
||||||
std::isdigit(macrocode[i+3]))
|
std::isdigit(macrocode[i+3]))
|
||||||
i += 3;
|
i += 3;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1979,9 +1979,17 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void macro_simple18() { // (1e-7)
|
void macro_simple18() { // (1e-7)
|
||||||
const char filedata[] = "#define A (1e-7)\n"
|
const char filedata1[] = "#define A (1e-7)\n"
|
||||||
"a=A;";
|
"a=A;";
|
||||||
ASSERT_EQUALS("\na=$($1e-7);", OurPreprocessor::expandMacros(filedata));
|
ASSERT_EQUALS("\na=$($1e-7);", OurPreprocessor::expandMacros(filedata1));
|
||||||
|
|
||||||
|
const char filedata2[] = "#define A (1E-7)\n"
|
||||||
|
"a=A;";
|
||||||
|
ASSERT_EQUALS("\na=$($1E-7);", OurPreprocessor::expandMacros(filedata2));
|
||||||
|
|
||||||
|
const char filedata3[] = "#define A (1e+7)\n"
|
||||||
|
"a=A;";
|
||||||
|
ASSERT_EQUALS("\na=$($1e+7);", OurPreprocessor::expandMacros(filedata3));
|
||||||
}
|
}
|
||||||
|
|
||||||
void macroInMacro1() {
|
void macroInMacro1() {
|
||||||
|
|
Loading…
Reference in New Issue