From 51858ecc96d78828ae777a0603bb9ccaae67a129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 28 May 2017 15:23:15 +0200 Subject: [PATCH] bump simplecpp --- externals/simplecpp/simplecpp.cpp | 44 ++++++++++++++++++++++--------- externals/simplecpp/simplecpp.h | 2 +- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 6b74253f6..9a8adad09 100644 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -19,21 +19,16 @@ #include "simplecpp.h" #include -#include #include -#include -#include -#include -#include -#include -#include #include -#include // strtoll, etc -#include +#include #include #include +#include +#include #include -#include +#include +#include #if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) #define NOMINMAX @@ -533,6 +528,18 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen if (currentToken.size() < 2U) // TODO report return; + + std::string s = currentToken; + std::string::size_type pos; + while ((pos = s.find_first_of("\r\n")) != std::string::npos) { + s.erase(pos,1); + } + + push_back(new Token(s, location)); // push string without newlines + + location.adjust(currentToken); + + continue; } else { @@ -900,12 +907,25 @@ std::string simplecpp::TokenList::readUntil(std::istream &istr, const Location & std::string ret; ret += start; + bool backslash = false; char ch = 0; while (ch != end && ch != '\r' && ch != '\n' && istr.good()) { ch = (unsigned char)istr.get(); + if (backslash && ch == '\n') { + ch = 0; + backslash = false; + continue; + } + backslash = false; ret += ch; - if (ch == '\\') - ret += (unsigned char)istr.get(); + if (ch == '\\') { + const char next = (unsigned char)istr.get(); + if (next == '\r' || next == '\n') { + ret.erase(ret.size()-1U); + backslash = (next == '\r'); + } + ret += next; + } } if (!istr.good() || ch != end) { diff --git a/externals/simplecpp/simplecpp.h b/externals/simplecpp/simplecpp.h index a1a5ca7d9..76ee90d8e 100644 --- a/externals/simplecpp/simplecpp.h +++ b/externals/simplecpp/simplecpp.h @@ -20,6 +20,7 @@ #define simplecppH #include +#include #include #include #include @@ -27,7 +28,6 @@ #include #include - #ifdef _WIN32 # ifdef SIMPLECPP_EXPORT # define SIMPLECPP_LIB __declspec(dllexport)