Bump simplecpp

This commit is contained in:
Daniel Marjamäki 2021-02-21 19:13:16 +01:00
parent 627a5e75cc
commit c638edc8b4
1 changed files with 22 additions and 6 deletions

View File

@ -561,7 +561,7 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
portabilityBackslash(outputList, files, location);
if (currentToken[currentToken.size() - 1U] == '\\') {
++multiline;
currentToken.pop_back();
currentToken.erase(currentToken.size() - 1U);
} else {
ungetChar(istr, bom);
}
@ -606,7 +606,7 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
if (ch == '\"' && !prefix.empty() && *cback()->str().rbegin() == 'R') {
std::string delim;
currentToken = ch;
prefix.pop_back();
prefix.resize(prefix.size() - 1);
ch = readChar(istr,bom);
while (istr.good() && ch != '(' && ch != '\n') {
delim += ch;
@ -1147,7 +1147,7 @@ std::string simplecpp::TokenList::readUntil(std::istream &istr, const Location &
do {
next = readChar(istr, bom);
if (next == '\r' || next == '\n') {
ret.pop_back();
ret.erase(ret.size()-1U);
backslash = (next == '\r');
update_ch = false;
} else if (next == '\\')
@ -1744,7 +1744,18 @@ namespace simplecpp {
defToken = lastToken = tok2;
}
if (defToken) {
const bool def = (macros.find(defToken->str()) != macros.end());
std::string macroName = defToken->str();
if (defToken->next && defToken->next->op == '#' && defToken->next->next && defToken->next->next->op == '#' && defToken->next->next->next && defToken->next->next->next->name && sameline(defToken,defToken->next->next->next)) {
TokenList temp(files);
if (expandArg(&temp, defToken, parametertokens))
macroName = temp.cback()->str();
if (expandArg(&temp, defToken->next->next->next, parametertokens))
macroName += temp.cback()->str();
else
macroName += defToken->next->next->next->str();
lastToken = defToken->next->next->next;
}
const bool def = (macros.find(macroName) != macros.end());
output->push_back(newMacroToken(def ? "1" : "0", loc, true));
return lastToken->next;
}
@ -1880,7 +1891,6 @@ namespace simplecpp {
}
const Token *nextTok = B->next;
if (varargs && tokensB.empty() && tok->previous->str() == ",")
output->deleteToken(A);
else if (strAB != "," && macros.find(strAB) == macros.end()) {
@ -1888,6 +1898,12 @@ namespace simplecpp {
for (Token *b = tokensB.front(); b; b = b->next)
b->location = loc;
output->takeTokens(tokensB);
} else if (nextTok->op == '#' && nextTok->next->op == '#') {
TokenList output2(files);
output2.push_back(new Token(strAB, tok->location));
nextTok = expandHashHash(&output2, loc, nextTok, macros, expandedmacros, parametertokens);
output->deleteToken(A);
output->takeTokens(output2);
} else {
output->deleteToken(A);
TokenList tokens(files);
@ -2176,7 +2192,7 @@ namespace simplecpp {
// remove trailing dot if path ends with "/."
if (endsWith(path,"/."))
path.pop_back();
path.erase(path.size()-1);
// simplify ".."
pos = 1; // don't simplify ".." if path starts with that