From f69f7190a00bb974b3a38a36fd6940d63ccbe7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 6 Aug 2016 11:38:20 +0200 Subject: [PATCH] bump simplecpp (handling #define with multiline comments) --- externals/simplecpp/simplecpp.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index b44ab6c51..14706b24d 100644 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -81,6 +81,10 @@ unsigned long long stringToULL(const std::string &s) return ret; } +bool startsWith(const std::string &str, const std::string &s) { + return (str.size() >= s.size() && str.compare(0, s.size(), s) == 0); +} + bool endsWith(const std::string &s, const std::string &e) { return (s.size() >= e.size() && s.compare(s.size() - e.size(), e.size(), e) == 0); } @@ -400,11 +404,19 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen ch = readChar(istr,bom); } // multiline.. + std::string::size_type pos = 0; while ((pos = currentToken.find("\\\n",pos)) != std::string::npos) { currentToken.erase(pos,2); ++multiline; } + if (multiline || startsWith(lastLine(10),"# ")) { + pos = 0; + while ((pos = currentToken.find("\n",pos)) != std::string::npos) { + currentToken.erase(pos,1); + ++multiline; + } + } } // string / char literal