From e5949b5ce8a4ccf4e04a3506bc1c7d15c77b1710 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 12 Sep 2016 13:22:23 +0200 Subject: [PATCH] Fix build on GCC 4.9 GCC 4.9 doesn't like reassigning a std::stringstream. http://hydra.nixos.org/build/40371644 --- src/nix-build/nix-build.cc | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 83ed25911..248474d53 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -24,7 +24,7 @@ std::vector shellwords(const string & s) std::regex whitespace("^(\\s+).*"); auto begin = s.cbegin(); std::vector res; - std::stringstream cur; + std::string cur; enum state { sBegin, sQuote @@ -35,31 +35,28 @@ std::vector shellwords(const string & s) if (st == sBegin) { std::smatch match; if (regex_search(it, s.cend(), match, whitespace)) { - cur << string(begin, it); - res.push_back(cur.str()); - cur = stringstream{}; + cur.append(begin, it); + res.push_back(cur); + cur.clear(); it = match[1].second; begin = it; } } switch (*it) { case '"': - cur << string(begin, it); + cur.append(begin, it); begin = it + 1; st = st == sBegin ? sQuote : sBegin; break; case '\\': /* 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; break; } } - cur << string(begin, it); - auto last = cur.str(); - if (!last.empty()) { - res.push_back(std::move(last)); - } + cur.append(begin, it); + if (!cur.empty()) res.push_back(cur); return res; }