From 46b32368147e7975bf98826c30eed48e22ba07b4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Jan 2018 12:46:58 +0200 Subject: Implement manual copying of process_path Also fix bug in move ctor/assignment. --- libbutl/process.ixx | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'libbutl/process.ixx') diff --git a/libbutl/process.ixx b/libbutl/process.ixx index a0e2de6..cc5170f 100644 --- a/libbutl/process.ixx +++ b/libbutl/process.ixx @@ -22,34 +22,52 @@ namespace butl inline process_path:: process_path (process_path&& p) - : initial (p.initial), - recall (std::move (p.recall)), + : recall (std::move (p.recall)), effect (std::move (p.effect)), args0_ (p.args0_) { + initial = p.initial != p.recall.string ().c_str () + ? p.initial + : recall.string ().c_str (); + p.args0_ = nullptr; } inline process_path& process_path:: operator= (process_path&& p) { - if (this != &p) { if (args0_ != nullptr) - *args0_ = initial; + *args0_ = initial; // Restore. - initial = p.initial; recall = std::move (p.recall); effect = std::move (p.effect); args0_ = p.args0_; + initial = p.initial != p.recall.string ().c_str () + ? p.initial + : recall.string ().c_str (); + p.args0_ = nullptr; } return *this; } + inline process_path:: + process_path (const process_path& p, bool init) + : recall (p.recall), effect (p.effect) + { + assert (p.args0_ == nullptr); + + if (!p.empty ()) + { + assert (init == (p.initial != p.recall.string ().c_str ())); + initial = init ? p.initial : recall.string ().c_str (); + } + } + inline const char* process_path:: recall_string () const { -- cgit v1.1