From c638edc8b48bc544e277c4d8b14d520f42e42b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 21 Feb 2021 19:13:16 +0100 Subject: [PATCH] Bump simplecpp --- externals/simplecpp/simplecpp.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 2cb65f052..7d48a7159 100644 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -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