diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-08-21 10:36:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-08-21 10:36:53 +0200 |
commit | 338a16f0df3c45bcbeaf5e7ffd0b4dc515e11502 (patch) | |
tree | feaadfd0073051f4c41083d73bf89ce20bc7cdc6 | |
parent | 41f958c4cf68541a48b20ceb608afe2308a6e6a7 (diff) |
Make process_env usable with C array of environment variables
-rw-r--r-- | libbutl/process-run.txx | 5 | ||||
-rw-r--r-- | libbutl/process.mxx | 14 |
2 files changed, 15 insertions, 4 deletions
diff --git a/libbutl/process-run.txx b/libbutl/process-run.txx index f6c14f5..85e51e2 100644 --- a/libbutl/process-run.txx +++ b/libbutl/process-run.txx @@ -5,9 +5,8 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason. { template <typename V> - process_env:: - process_env (const process_path& p, const V& v) - : process_env (p) + void process_env:: + init_vars (const V& v) { if (!v.empty ()) { diff --git a/libbutl/process.mxx b/libbutl/process.mxx index a536fe9..8f8b930 100644 --- a/libbutl/process.mxx +++ b/libbutl/process.mxx @@ -536,7 +536,8 @@ LIBBUTL_MODEXPORT namespace butl : process_env (p, v) {cwd = &c;} template <typename V> - process_env (const process_path& p, const V& v); + process_env (const process_path& p, const V& v) + : process_env (p) {init_vars (v);} process_env (const char* p, const dir_path& c = dir_path (), @@ -578,6 +579,17 @@ LIBBUTL_MODEXPORT namespace butl : process_env (p.string (), v) {} private: + template <typename V> + void + init_vars (const V&); + + template <std::size_t N> + void + init_vars (const char* const (&v)[N]) + { + vars = v; + } + process_path path_; small_vector<const char*, 3> vars_; }; |