bump simplecpp

This commit is contained in:
Daniel Marjamäki 2018-02-14 22:14:42 +01:00
parent f5b0f1f792
commit ae7fbb50c7
1 changed files with 15 additions and 4 deletions

View File

@ -466,7 +466,7 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
TokenString currentToken;
if (cback() && cback()->previous && cback()->previous->op == '#' && (lastLine() == "# error" || lastLine() == "# warning")) {
if (cback() && cback()->location.line == location.line && cback()->previous && cback()->previous->op == '#' && (lastLine() == "# error" || lastLine() == "# warning")) {
while (istr.good() && ch != '\r' && ch != '\n') {
currentToken += ch;
ch = readChar(istr, bom);
@ -575,14 +575,20 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
std::string s = currentToken;
std::string::size_type pos;
int newlines = 0;
while ((pos = s.find_first_of("\r\n")) != std::string::npos) {
s.erase(pos,1);
newlines++;
}
push_back(new Token(s, location)); // push string without newlines
if (newlines > 0 && lastLine().compare(0,9,"# define ") == 0) {
multiline += newlines;
location.adjust(s);
} else {
location.adjust(currentToken);
}
continue;
}
@ -1332,7 +1338,7 @@ namespace simplecpp {
if (it != macros.end() && expandedmacros.find(tok->str) == expandedmacros.end()) {
const Macro &m = it->second;
if (!m.functionLike()) {
m.expand(tokens, tok, macros, files);
m.expand(tokens, tok->location, tok, macros, expandedmacros);
expanded = true;
}
}
@ -1500,6 +1506,11 @@ namespace simplecpp {
return tok->next;
}
if (!sameline(tok, tok->next)) {
output->takeTokens(temp);
return tok->next;
}
const std::map<TokenString, Macro>::const_iterator it = macros.find(temp.cback()->str);
if (it == macros.end() || expandedmacros.find(temp.cback()->str) != expandedmacros.end()) {
output->takeTokens(temp);