|
@@ -164,33 +164,36 @@ static std::string extractAllGeneratorExpressions(
|
|
|
std::string result;
|
|
std::string result;
|
|
|
std::string::size_type pos = 0;
|
|
std::string::size_type pos = 0;
|
|
|
std::string::size_type lastPos = pos;
|
|
std::string::size_type lastPos = pos;
|
|
|
- // stack of { Generator Expression Name, Start Position of Value }
|
|
|
|
|
- std::stack<std::pair<std::string, std::string::size_type>> genexps;
|
|
|
|
|
|
|
+ std::stack<char const*> starts; // indices of "$<"
|
|
|
|
|
+ std::stack<char const*> colons; // indices of ":"
|
|
|
while ((pos = input.find("$<", lastPos)) != std::string::npos) {
|
|
while ((pos = input.find("$<", lastPos)) != std::string::npos) {
|
|
|
result += input.substr(lastPos, pos - lastPos);
|
|
result += input.substr(lastPos, pos - lastPos);
|
|
|
|
|
+ starts.push(input.c_str() + pos);
|
|
|
pos += 2;
|
|
pos += 2;
|
|
|
char const* c = input.c_str() + pos;
|
|
char const* c = input.c_str() + pos;
|
|
|
- char const* cName = c;
|
|
|
|
|
char const* const cStart = c;
|
|
char const* const cStart = c;
|
|
|
for (; *c; ++c) {
|
|
for (; *c; ++c) {
|
|
|
if (cmGeneratorExpression::StartsWithGeneratorExpression(c)) {
|
|
if (cmGeneratorExpression::StartsWithGeneratorExpression(c)) {
|
|
|
|
|
+ starts.push(c);
|
|
|
++c;
|
|
++c;
|
|
|
- cName = c + 1;
|
|
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- if (c[0] == ':' && cName) {
|
|
|
|
|
- genexps.push({ input.substr(pos + (cName - cStart), c - cName),
|
|
|
|
|
- pos + (c + 1 - cStart) });
|
|
|
|
|
- cName = nullptr;
|
|
|
|
|
|
|
+ if (c[0] == ':') {
|
|
|
|
|
+ if (colons.size() < starts.size()) {
|
|
|
|
|
+ colons.push(c);
|
|
|
|
|
+ }
|
|
|
} else if (c[0] == '>') {
|
|
} else if (c[0] == '>') {
|
|
|
- if (!cName && !genexps.empty()) {
|
|
|
|
|
- if (collected) {
|
|
|
|
|
- (*collected)[genexps.top().first].push_back(input.substr(
|
|
|
|
|
- genexps.top().second, pos + c - cStart - genexps.top().second));
|
|
|
|
|
- }
|
|
|
|
|
- genexps.pop();
|
|
|
|
|
|
|
+ if (collected && !starts.empty() && !colons.empty()) {
|
|
|
|
|
+ (*collected)[std::string(starts.top() + 2, colons.top())].push_back(
|
|
|
|
|
+ std::string(colons.top() + 1, c));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!starts.empty()) {
|
|
|
|
|
+ starts.pop();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!colons.empty()) {
|
|
|
|
|
+ colons.pop();
|
|
|
}
|
|
}
|
|
|
- if (genexps.empty()) {
|
|
|
|
|
|
|
+ if (starts.empty()) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -202,7 +205,7 @@ static std::string extractAllGeneratorExpressions(
|
|
|
pos += traversed;
|
|
pos += traversed;
|
|
|
lastPos = pos;
|
|
lastPos = pos;
|
|
|
}
|
|
}
|
|
|
- if (genexps.empty()) {
|
|
|
|
|
|
|
+ if (starts.empty()) {
|
|
|
result += input.substr(lastPos);
|
|
result += input.substr(lastPos);
|
|
|
}
|
|
}
|
|
|
return cmGeneratorExpression::StripEmptyListElements(result);
|
|
return cmGeneratorExpression::StripEmptyListElements(result);
|