From ae7fbb50c7915434643291338562486a3ff786fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 14 Feb 2018 22:14:42 +0100 Subject: [PATCH] bump simplecpp --- externals/simplecpp/simplecpp.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 586a68e94..4fea10622 100644 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -466,7 +466,7 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen TokenString currentToken; - if (cback() && cback()->previous && cback()->previous->op == '#' && (lastLine() == "# error" || lastLine() == "# warning")) { + if (cback() && cback()->location.line == location.line && cback()->previous && cback()->previous->op == '#' && (lastLine() == "# error" || lastLine() == "# warning")) { while (istr.good() && ch != '\r' && ch != '\n') { currentToken += ch; ch = readChar(istr, bom); @@ -575,14 +575,20 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen std::string s = currentToken; std::string::size_type pos; + int newlines = 0; while ((pos = s.find_first_of("\r\n")) != std::string::npos) { s.erase(pos,1); + newlines++; } push_back(new Token(s, location)); // push string without newlines - location.adjust(currentToken); - + if (newlines > 0 && lastLine().compare(0,9,"# define ") == 0) { + multiline += newlines; + location.adjust(s); + } else { + location.adjust(currentToken); + } continue; } @@ -1332,7 +1338,7 @@ namespace simplecpp { if (it != macros.end() && expandedmacros.find(tok->str) == expandedmacros.end()) { const Macro &m = it->second; if (!m.functionLike()) { - m.expand(tokens, tok, macros, files); + m.expand(tokens, tok->location, tok, macros, expandedmacros); expanded = true; } } @@ -1500,6 +1506,11 @@ namespace simplecpp { return tok->next; } + if (!sameline(tok, tok->next)) { + output->takeTokens(temp); + return tok->next; + } + const std::map::const_iterator it = macros.find(temp.cback()->str); if (it == macros.end() || expandedmacros.find(temp.cback()->str) != expandedmacros.end()) { output->takeTokens(temp);