about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-09-12T11·22+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-09-12T11·22+0200
commite5949b5ce8a4ccf4e04a3506bc1c7d15c77b1710 (patch)
treec7e3eb5fa139ab804b82d405c08232c503460a68
parent5039d3b9de811a9d8392626850aab8f7135e683c (diff)
Fix build on GCC 4.9
GCC 4.9 doesn't like reassigning a std::stringstream.

http://hydra.nixos.org/build/40371644
-rwxr-xr-xsrc/nix-build/nix-build.cc19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc
index 83ed25911275..248474d5316a 100755
--- a/src/nix-build/nix-build.cc
+++ b/src/nix-build/nix-build.cc
@@ -24,7 +24,7 @@ std::vector<string> shellwords(const string & s)
     std::regex whitespace("^(\\s+).*");
     auto begin = s.cbegin();
     std::vector<string> res;
-    std::stringstream cur;
+    std::string cur;
     enum state {
         sBegin,
         sQuote
@@ -35,31 +35,28 @@ std::vector<string> 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;
 }