bump simplecpp

This commit is contained in:
Daniel Marjamäki 2016-07-21 18:58:11 +02:00
parent 4b1f79f243
commit 6d10b50434
2 changed files with 23 additions and 8 deletions

View File

@ -1219,29 +1219,30 @@ bool hasFile(const std::map<std::string, simplecpp::TokenList *> &filedata, cons
std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector<std::string> &fileNumbers, const struct simplecpp::DUI &dui, simplecpp::OutputList *outputList)
{
simplecpp::TokenList rawtokens2(rawtokens);
rawtokens2.removeComments();
std::map<std::string, simplecpp::TokenList*> ret;
std::list<const Token *> 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<std::string, simplecpp::TokenList*> 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());

View File

@ -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;
};