bump simplecpp
This commit is contained in:
parent
fd74d455ce
commit
e8d1e4b19d
|
@ -1471,6 +1471,25 @@ namespace simplecpp {
|
||||||
return tok2->next;
|
return tok2->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (tok->str == DEFINED) {
|
||||||
|
const Token *tok2 = tok->next;
|
||||||
|
const Token *tok3 = tok2 ? tok2->next : NULL;
|
||||||
|
const Token *tok4 = tok3 ? tok3->next : NULL;
|
||||||
|
const Token *defToken = NULL;
|
||||||
|
const Token *lastToken = NULL;
|
||||||
|
if (sameline(tok, tok4) && tok2->op == '(' && tok3->name && tok4->op == ')') {
|
||||||
|
defToken = tok3;
|
||||||
|
lastToken = tok4;
|
||||||
|
} else if (sameline(tok,tok2) && tok2->name) {
|
||||||
|
defToken = lastToken = tok2;
|
||||||
|
}
|
||||||
|
if (defToken) {
|
||||||
|
const bool def = (macros.find(defToken->str) != macros.end());
|
||||||
|
output->push_back(newMacroToken(def ? "1" : "0", loc, true));
|
||||||
|
return lastToken->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
output->push_back(newMacroToken(tok->str, loc, true));
|
output->push_back(newMacroToken(tok->str, loc, true));
|
||||||
return tok->next;
|
return tok->next;
|
||||||
}
|
}
|
||||||
|
@ -1708,23 +1727,23 @@ namespace simplecpp {
|
||||||
// replace backslash separators
|
// replace backslash separators
|
||||||
std::replace(path.begin(), path.end(), '\\', '/');
|
std::replace(path.begin(), path.end(), '\\', '/');
|
||||||
|
|
||||||
// "./" at the start
|
// remove "./"
|
||||||
if (path.size() > 3 && path.compare(0,2,"./") == 0 && path[2] != '/')
|
|
||||||
path.erase(0,2);
|
|
||||||
|
|
||||||
// remove "/./"
|
|
||||||
pos = 0;
|
pos = 0;
|
||||||
while ((pos = path.find("/./",pos)) != std::string::npos) {
|
while ((pos = path.find("./",pos)) != std::string::npos) {
|
||||||
|
if (pos == 0 || path[pos - 1U] == '/')
|
||||||
path.erase(pos,2);
|
path.erase(pos,2);
|
||||||
|
else
|
||||||
|
pos += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove "xyz/../"
|
// remove "xyz/../"
|
||||||
pos = 1U;
|
pos = 1U;
|
||||||
while ((pos = path.find("/../", pos)) != std::string::npos) {
|
while ((pos = path.find("/../", pos)) != std::string::npos) {
|
||||||
const std::string::size_type pos1 = path.rfind('/', pos - 1U);
|
const std::string::size_type pos1 = path.rfind('/', pos - 1U);
|
||||||
if (pos1 == std::string::npos)
|
if (pos1 == std::string::npos) {
|
||||||
pos++;
|
path.erase(0,pos+4);
|
||||||
else {
|
pos = 0;
|
||||||
|
} else {
|
||||||
path.erase(pos1,pos-pos1+3);
|
path.erase(pos1,pos-pos1+3);
|
||||||
pos = std::min((std::string::size_type)1, pos1);
|
pos = std::min((std::string::size_type)1, pos1);
|
||||||
}
|
}
|
||||||
|
@ -2039,7 +2058,6 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
|
||||||
std::stack<int> ifstates;
|
std::stack<int> ifstates;
|
||||||
ifstates.push(TRUE);
|
ifstates.push(TRUE);
|
||||||
|
|
||||||
std::list<TokenList *> includes;
|
|
||||||
std::stack<const Token *> includetokenstack;
|
std::stack<const Token *> includetokenstack;
|
||||||
|
|
||||||
std::set<std::string> pragmaOnce;
|
std::set<std::string> pragmaOnce;
|
||||||
|
|
Loading…
Reference in New Issue