aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/command.mxx1
-rw-r--r--libbutl/process.ixx48
-rw-r--r--libbutl/process.mxx8
3 files changed, 45 insertions, 12 deletions
diff --git a/libbutl/command.mxx b/libbutl/command.mxx
index 354788d..e2a9737 100644
--- a/libbutl/command.mxx
+++ b/libbutl/command.mxx
@@ -80,5 +80,4 @@ LIBBUTL_MODEXPORT namespace butl
const optional<command_substitution_map>& = nullopt,
char subst = '@',
const std::function<command_callback>& = {});
-
}
diff --git a/libbutl/process.ixx b/libbutl/process.ixx
index 0aa23fa..accc57b 100644
--- a/libbutl/process.ixx
+++ b/libbutl/process.ixx
@@ -22,13 +22,13 @@ namespace butl
inline process_path::
process_path (process_path&& p)
- : recall (std::move (p.recall)),
- effect (std::move (p.effect)),
+ : effect (std::move (p.effect)),
args0_ (p.args0_)
{
- initial = p.initial != p.recall.string ().c_str ()
- ? p.initial
- : recall.string ().c_str ();
+ bool init (p.initial != p.recall.string ().c_str ());
+
+ recall = std::move (p.recall);
+ initial = init ? p.initial : recall.string ().c_str ();
p.args0_ = nullptr;
}
@@ -41,14 +41,13 @@ namespace butl
if (args0_ != nullptr)
*args0_ = initial; // Restore.
- recall = std::move (p.recall);
- effect = std::move (p.effect);
- args0_ = p.args0_;
+ bool init (p.initial != p.recall.string ().c_str ());
- initial = p.initial != p.recall.string ().c_str ()
- ? p.initial
- : recall.string ().c_str ();
+ recall = std::move (p.recall);
+ effect = std::move (p.effect);
+ initial = init ? p.initial : recall.string ().c_str ();
+ args0_ = p.args0_;
p.args0_ = nullptr;
}
@@ -237,4 +236,31 @@ namespace butl
using namespace std::chrono;
return timed_wait (duration_cast<milliseconds> (d));
}
+
+ // process_env
+ //
+ inline process_env::
+ process_env (process_env&& e)
+ {
+ *this = std::move (e);
+ }
+
+ inline process_env& process_env::
+ operator= (process_env&& e)
+ {
+ if (this != &e)
+ {
+ cwd = e.cwd;
+
+ bool sp (e.path == &e.path_);
+ path_ = std::move (e.path_);
+ path = sp ? &path_ : e.path;
+
+ bool sv (e.vars == e.vars_.data ());
+ vars_ = std::move (e.vars_);
+ vars = sv ? vars_.data () : e.vars;
+ }
+
+ return *this;
+ }
}
diff --git a/libbutl/process.mxx b/libbutl/process.mxx
index 655650e..13438be 100644
--- a/libbutl/process.mxx
+++ b/libbutl/process.mxx
@@ -588,6 +588,14 @@ LIBBUTL_MODEXPORT namespace butl
process_env (const butl::path& p, const V& v)
: process_env (p.string (), v) {}
+ // Moveable-only type.
+ //
+ process_env (process_env&&);
+ process_env& operator= (process_env&&);
+
+ process_env (const process_env&) = delete;
+ process_env& operator= (const process_env&) = delete;
+
private:
template <typename V>
void