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