bump simplecpp

This commit is contained in:
Daniel Marjamäki 2016-08-04 22:53:10 +02:00
parent a0624344ce
commit cbfeae0ff7
2 changed files with 30 additions and 14 deletions

View File

@ -1058,6 +1058,15 @@ private:
unsigned int par = 0;
const Token *tok = lpar;
while (sameline(lpar, tok)) {
if (tok->op == '#' && sameline(tok,tok->next) && tok->next->op == '#' && sameline(tok,tok->next->next)) {
// A##B => AB
const std::string strB(expandArgStr(tok->next->next, parametertokens));
if (variadic && strB.empty() && tok->previous->op == ',')
tokens->deleteToken(tokens->back());
else
tokens->back()->setstr(tokens->back()->str + strB);
tok = tok->next->next->next;
} else {
if (!expandArg(tokens, tok, tok->location, macros, expandedmacros1, expandedmacros, parametertokens))
tokens->push_back(new Token(*tok));
if (tok->op == '(')
@ -1069,6 +1078,7 @@ private:
}
tok = tok->next;
}
}
return sameline(lpar,tok) ? tok : NULL;
}
@ -1196,10 +1206,16 @@ private:
// #123 => "123"
TokenList tokenListHash(files);
tok = expandToken(&tokenListHash, loc, tok, macros, expandedmacros1, expandedmacros, parametertokens2);
std::string s;
for (const Token *hashtok = tokenListHash.cfront(); hashtok; hashtok = hashtok->next)
s += hashtok->str;
output->push_back(newMacroToken('\"' + s + '\"', loc, expandedmacros1.empty()));
std::ostringstream ostr;
for (const Token *hashtok = tokenListHash.cfront(); hashtok; hashtok = hashtok->next) {
for (unsigned int i = 0; i < hashtok->str.size(); i++) {
unsigned char c = hashtok->str[i];
if (c == '\"' || c == '\\' || c == '\'')
ostr << '\\';
ostr << c;
}
}
output->push_back(newMacroToken('\"' + ostr.str() + '\"', loc, expandedmacros1.empty()));
}
}

View File

@ -1446,7 +1446,7 @@ private:
void stringify5() const {
const char filedata[] = "#define A(x) a(#x,x)\n"
"A(foo(\"\\\"\"))\n";
ASSERT_EQUALS("\na ( \"foo(\"\\\"\")\" , foo ( \"\\\"\" ) )", OurPreprocessor::expandMacros(filedata));
ASSERT_EQUALS("\na ( \"foo(\\\"\\\\\\\"\\\")\" , foo ( \"\\\"\" ) )", OurPreprocessor::expandMacros(filedata));
}
void pragma() {