From 60861654031db0544dff78be975890b658db4ad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 4 Dec 2016 12:10:28 +0100 Subject: [PATCH] bump simplecpp to rev c70bae00a9b92eca75767e547fad972cf011945f --- externals/simplecpp/simplecpp.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 9926a5a05..f27a935d1 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 } if (multiline || startsWith(lastLine(10),"# ")) { pos = 0; - while ((pos = currentToken.find("\n",pos)) != std::string::npos) { + while ((pos = currentToken.find('\n',pos)) != std::string::npos) { currentToken.erase(pos,1); ++multiline; } @@ -1646,7 +1646,7 @@ std::string simplifyPath(std::string path) { // remove "xyz/../" pos = 1U; while ((pos = path.find("/../", pos)) != std::string::npos) { - const std::string::size_type pos1 = path.rfind("/", pos - 1U); + const std::string::size_type pos1 = path.rfind('/', pos - 1U); if (pos1 == std::string::npos) pos++; else { @@ -1683,7 +1683,7 @@ void simplifySizeof(simplecpp::TokenList &expr, const std::mapnext) { if ((typeToken->str == "unsigned" || typeToken->str == "signed") && typeToken->next->name) continue; - if (typeToken->str == "*" && type.find("*") != std::string::npos) + if (typeToken->str == "*" && type.find('*') != std::string::npos) continue; if (!type.empty()) type += ' '; @@ -1931,8 +1931,8 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL std::map macros; for (std::list::const_iterator it = dui.defines.begin(); it != dui.defines.end(); ++it) { const std::string ¯ostr = *it; - const std::string::size_type eq = macrostr.find("="); - const std::string::size_type par = macrostr.find("("); + const std::string::size_type eq = macrostr.find('='); + const std::string::size_type par = macrostr.find('('); const std::string macroname = macrostr.substr(0, std::min(eq,par)); if (dui.undefined.find(macroname) != dui.undefined.end()) continue; @@ -1980,6 +1980,17 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL continue; } + if (ifstates.size() <= 1U && (rawtok->str == ELIF || rawtok->str == ELSE || rawtok->str == ENDIF)) { + simplecpp::Output err(files); + err.type = Output::SYNTAX_ERROR; + err.location = rawtok->location; + err.msg = "#" + rawtok->str + " without #if"; + if (outputList) + outputList->push_back(err); + output.clear(); + return; + } + if (ifstates.top() == TRUE && (rawtok->str == ERROR || rawtok->str == WARNING)) { if (outputList) { simplecpp::Output err(rawtok->location.files); @@ -2170,8 +2181,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL } else if (rawtok->str == ELSE) { ifstates.top() = (ifstates.top() == ELSE_IS_TRUE) ? TRUE : ALWAYS_FALSE; } else if (rawtok->str == ENDIF) { - if (ifstates.size() > 1U) - ifstates.pop(); + ifstates.pop(); } else if (rawtok->str == UNDEF) { if (ifstates.top() == TRUE) { const Token *tok = rawtok->next;