Fix build on GCC 4.9
GCC 4.9 doesn't like reassigning a std::stringstream. http://hydra.nixos.org/build/40371644
This commit is contained in:
parent
5039d3b9de
commit
e5949b5ce8
1 changed files with 8 additions and 11 deletions
|
@ -24,7 +24,7 @@ std::vector<string> shellwords(const string & s)
|
||||||
std::regex whitespace("^(\\s+).*");
|
std::regex whitespace("^(\\s+).*");
|
||||||
auto begin = s.cbegin();
|
auto begin = s.cbegin();
|
||||||
std::vector<string> res;
|
std::vector<string> res;
|
||||||
std::stringstream cur;
|
std::string cur;
|
||||||
enum state {
|
enum state {
|
||||||
sBegin,
|
sBegin,
|
||||||
sQuote
|
sQuote
|
||||||
|
@ -35,31 +35,28 @@ std::vector<string> shellwords(const string & s)
|
||||||
if (st == sBegin) {
|
if (st == sBegin) {
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
if (regex_search(it, s.cend(), match, whitespace)) {
|
if (regex_search(it, s.cend(), match, whitespace)) {
|
||||||
cur << string(begin, it);
|
cur.append(begin, it);
|
||||||
res.push_back(cur.str());
|
res.push_back(cur);
|
||||||
cur = stringstream{};
|
cur.clear();
|
||||||
it = match[1].second;
|
it = match[1].second;
|
||||||
begin = it;
|
begin = it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (*it) {
|
switch (*it) {
|
||||||
case '"':
|
case '"':
|
||||||
cur << string(begin, it);
|
cur.append(begin, it);
|
||||||
begin = it + 1;
|
begin = it + 1;
|
||||||
st = st == sBegin ? sQuote : sBegin;
|
st = st == sBegin ? sQuote : sBegin;
|
||||||
break;
|
break;
|
||||||
case '\\':
|
case '\\':
|
||||||
/* perl shellwords mostly just treats the next char as part of the string with no special processing */
|
/* perl shellwords mostly just treats the next char as part of the string with no special processing */
|
||||||
cur << string(begin, it);
|
cur.append(begin, it);
|
||||||
begin = ++it;
|
begin = ++it;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur << string(begin, it);
|
cur.append(begin, it);
|
||||||
auto last = cur.str();
|
if (!cur.empty()) res.push_back(cur);
|
||||||
if (!last.empty()) {
|
|
||||||
res.push_back(std::move(last));
|
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue