From 30354ee02697400345350893f2d58595925002b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 29 Jul 2016 13:05:35 +0200 Subject: [PATCH] bump simplecpp --- externals/simplecpp/simplecpp.cpp | 18 +++++++++++------- externals/simplecpp/simplecpp.h | 12 ++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index b7b911922..d331029eb 100644 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -96,7 +96,7 @@ void simplecpp::Location::adjust(const std::string &str) { return; } - for (unsigned int i = 0U; i < str.size(); ++i) { + for (std::size_t i = 0U; i < str.size(); ++i) { col++; if (str[i] == '\n' || str[i] == '\r') { col = 0; @@ -288,6 +288,10 @@ static unsigned short getAndSkipBOM(std::istream &istr) { return 0; } +bool isNameChar(unsigned char ch) { + return std::isalnum(ch) || ch == '_' || ch == '$'; +} + void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filename, OutputList *outputList) { std::stack loc; @@ -344,8 +348,8 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen TokenString currentToken; // number or name - if (std::isalnum(ch) || ch == '_') { - while (istr.good() && (std::isalnum(ch) || ch == '_')) { + if (isNameChar(ch)) { + while (istr.good() && isNameChar(ch)) { currentToken += ch; ch = readChar(istr,bom); } @@ -1440,7 +1444,7 @@ bool hasFile(const std::map &filedata, cons } } -std::map simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector &fileNumbers, const struct simplecpp::DUI &dui, simplecpp::OutputList *outputList) +std::map simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector &fileNumbers, const simplecpp::DUI &dui, simplecpp::OutputList *outputList) { std::map ret; @@ -1487,7 +1491,7 @@ std::map simplecpp::load(const simplecpp::To return ret; } -void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenList &rawtokens, std::vector &files, const std::map &filedata, const struct simplecpp::DUI &dui, simplecpp::OutputList *outputList, std::list *macroUsage) +void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenList &rawtokens, std::vector &files, const std::map &filedata, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, std::list *macroUsage) { std::map sizeOfType(rawtokens.sizeOfType); sizeOfType.insert(std::pair(std::string("char"), sizeof(char))); @@ -1562,7 +1566,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL err.type = rawtok->str == ERROR ? Output::ERROR : Output::WARNING; err.location = rawtok->location; for (const Token *tok = rawtok->next; tok && sameline(rawtok,tok); tok = tok->next) { - if (!err.msg.empty() && std::isalnum((unsigned char)tok->str[0])) + if (!err.msg.empty() && isNameChar(tok->str[0])) err.msg += ' '; err.msg += tok->str; } @@ -1765,7 +1769,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL const Macro ¯o = macroIt->second; const std::list &usage = macro.usage(); for (std::list::const_iterator usageIt = usage.begin(); usageIt != usage.end(); ++usageIt) { - struct MacroUsage mu(usageIt->files); + MacroUsage mu(usageIt->files); mu.macroName = macro.name(); mu.macroLocation = macro.defineLocation(); mu.useLocation = *usageIt; diff --git a/externals/simplecpp/simplecpp.h b/externals/simplecpp/simplecpp.h index 3a19ea67a..d283c0c15 100644 --- a/externals/simplecpp/simplecpp.h +++ b/externals/simplecpp/simplecpp.h @@ -105,9 +105,9 @@ public: } void flags() { - name = (str[0] == '_' || std::isalpha(str[0])); + name = (std::isalpha((unsigned char)str[0]) || str[0] == '_' || str[0] == '$'); comment = (str.compare(0, 2, "//") == 0 || str.compare(0, 2, "/*") == 0); - number = std::isdigit(str[0]) || (str.size() > 1U && str[0] == '-' && std::isdigit(str[1])); + number = std::isdigit((unsigned char)str[0]) || (str.size() > 1U && str[0] == '-' && std::isdigit((unsigned char)str[1])); op = (str.size() == 1U) ? str[0] : '\0'; } @@ -120,9 +120,9 @@ public: bool startsWithOneOf(const char c[]) const; bool endsWithOneOf(const char c[]) const; - char op; const TokenString &str; TokenString macro; + char op; bool comment; bool name; bool number; @@ -162,7 +162,7 @@ struct SIMPLECPP_LIB Output { std::string msg; }; -typedef std::list OutputList; +typedef std::list OutputList; /** List of tokens. */ class SIMPLECPP_LIB TokenList { @@ -271,7 +271,7 @@ struct SIMPLECPP_LIB DUI { std::list includePaths; }; -SIMPLECPP_LIB std::map load(const TokenList &rawtokens, std::vector &filenames, const struct DUI &dui, OutputList *outputList = 0); +SIMPLECPP_LIB std::map load(const TokenList &rawtokens, std::vector &filenames, const DUI &dui, OutputList *outputList = 0); /** * Preprocess @@ -287,7 +287,7 @@ SIMPLECPP_LIB std::map load(const TokenList &rawtokens, * * @todo simplify interface */ -SIMPLECPP_LIB void preprocess(TokenList &output, const TokenList &rawtokens, std::vector &files, const std::map &filedata, const struct DUI &dui, OutputList *outputList = 0, std::list *macroUsage = 0); +SIMPLECPP_LIB void preprocess(TokenList &output, const TokenList &rawtokens, std::vector &files, const std::map &filedata, const DUI &dui, OutputList *outputList = 0, std::list *macroUsage = 0); } #endif