From 6d10b50434bc16a120aba406f8f0e0e1718515d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 21 Jul 2016 18:58:11 +0200 Subject: [PATCH] bump simplecpp --- externals/simplecpp/simplecpp.cpp | 17 +++++++++-------- externals/simplecpp/simplecpp.h | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 41fe390fb..5f495632c 100644 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -1219,29 +1219,30 @@ 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) { - simplecpp::TokenList rawtokens2(rawtokens); - rawtokens2.removeComments(); - std::map ret; std::list filelist; - for (const Token *rawtok = rawtokens2.cbegin(); rawtok || !filelist.empty(); rawtok = rawtok->next) { + for (const Token *rawtok = rawtokens.cbegin(); rawtok || !filelist.empty(); rawtok = rawtok->next) { if (rawtok == NULL) { rawtok = filelist.back(); filelist.pop_back(); } - if (rawtok->op != '#' || sameline(rawtok->previous, rawtok)) + if (rawtok->op != '#' || sameline(rawtok->previousSkipComments(), rawtok)) continue; - rawtok = rawtok->next; + rawtok = rawtok->nextSkipComments(); if (!rawtok || rawtok->str != INCLUDE) continue; const std::string &sourcefile = rawtok->location.file(); - const std::string header(rawtok->next->str.substr(1U, rawtok->next->str.size() - 2U)); + const Token *htok = rawtok->nextSkipComments(); + if (!sameline(rawtok, htok)) + continue; + + const std::string header(htok->str.substr(1U, htok->str.size() - 2U)); if (hasFile(ret, sourcefile, header, dui)) continue; @@ -1252,7 +1253,7 @@ std::map simplecpp::load(const simplecpp::To ret[header2] = 0; - TokenList *tokens = new TokenList(f, fileNumbers, header2); + TokenList *tokens = new TokenList(f, fileNumbers, header2, outputList); ret[header2] = tokens; if (tokens->cbegin()) filelist.push_back(tokens->cbegin()); diff --git a/externals/simplecpp/simplecpp.h b/externals/simplecpp/simplecpp.h index 28de96d61..4bbe9abc2 100644 --- a/externals/simplecpp/simplecpp.h +++ b/externals/simplecpp/simplecpp.h @@ -115,6 +115,20 @@ public: Location location; Token *previous; Token *next; + + const Token *previousSkipComments() const { + const Token *tok = this->previous; + while (tok && tok->comment) + tok = tok->previous; + return tok; + } + + const Token *nextSkipComments() const { + const Token *tok = this->next; + while (tok && tok->comment) + tok = tok->next; + return tok; + } private: TokenString string; };