Preprocessor: don't insert macroChar inside .1 and 1. tokens
This commit is contained in:
parent
a1b0d190df
commit
2f91539d1d
|
@ -3151,7 +3151,18 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file
|
||||||
chr = !chr;
|
chr = !chr;
|
||||||
else if (str || chr)
|
else if (str || chr)
|
||||||
continue;
|
continue;
|
||||||
else if (std::isalnum(macrocode[i]) || macrocode[i] == '_') {
|
else if (macrocode[i] == '.') { // 5. / .5
|
||||||
|
if ((i > 0U && std::isdigit(macrocode[i-1])) ||
|
||||||
|
(i+1 < macrocode.size() && std::isdigit(macrocode[i+1]))) {
|
||||||
|
if (i > 0U && !std::isdigit(macrocode[i-1])) {
|
||||||
|
macrocode.insert(i, 1U, macroChar);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
if (i<macrocode.size() && std::isdigit(macrocode[i]))
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
} else if (std::isalnum(macrocode[i]) || macrocode[i] == '_') {
|
||||||
if ((i > 0U) &&
|
if ((i > 0U) &&
|
||||||
(!std::isalnum(macrocode[i-1])) &&
|
(!std::isalnum(macrocode[i-1])) &&
|
||||||
(macrocode[i-1] != '_') &&
|
(macrocode[i-1] != '_') &&
|
||||||
|
|
|
@ -2002,6 +2002,14 @@ private:
|
||||||
const char filedata5[] = "#define A (1.7f)\n"
|
const char filedata5[] = "#define A (1.7f)\n"
|
||||||
"a=A;";
|
"a=A;";
|
||||||
ASSERT_EQUALS("\na=$($1.7f);", OurPreprocessor::expandMacros(filedata5));
|
ASSERT_EQUALS("\na=$($1.7f);", OurPreprocessor::expandMacros(filedata5));
|
||||||
|
|
||||||
|
const char filedata6[] = "#define A (.1)\n"
|
||||||
|
"a=A;";
|
||||||
|
ASSERT_EQUALS("\na=$($.1);", OurPreprocessor::expandMacros(filedata6));
|
||||||
|
|
||||||
|
const char filedata7[] = "#define A (1.)\n"
|
||||||
|
"a=A;";
|
||||||
|
ASSERT_EQUALS("\na=$($1.);", OurPreprocessor::expandMacros(filedata7));
|
||||||
}
|
}
|
||||||
|
|
||||||
void macroInMacro1() {
|
void macroInMacro1() {
|
||||||
|
|
Loading…
Reference in New Issue