aboutsummaryrefslogtreecommitdiff
path: root/libbutl/process.mxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-03-09 16:06:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-03-09 16:06:53 +0200
commitf3eef5c4ddfa54fa7f6d155e90721cde318cc6f2 (patch)
treeb3454d7718a3cd9267bfef252669a22536c24065 /libbutl/process.mxx
parent254ae3cdcfc3d729aa102c6340c431c4060c8ca4 (diff)
Ignore NULL arguments in process_run
Diffstat (limited to 'libbutl/process.mxx')
-rw-r--r--libbutl/process.mxx23
1 files changed, 16 insertions, 7 deletions
diff --git a/libbutl/process.mxx b/libbutl/process.mxx
index 39a5d92..4a9c3cd 100644
--- a/libbutl/process.mxx
+++ b/libbutl/process.mxx
@@ -486,8 +486,9 @@ LIBBUTL_MODEXPORT namespace butl
//
// The A arguments can be anything convertible to const char* via the
// overloaded process_arg_as() (see below). Out of the box you can use const
- // char*, std::string, path/dir_path, (as well as [small_]vector[_view] of
- // these), and numeric types (as well as optional<T> of all the above).
+ // char* (with NULL values ignored), std::string, path/dir_path, (as well as
+ // [small_]vector[_view] of these), numeric types, as well as optional<T> of
+ // all the above with absent arguments ignored.
//
struct process_env
{
@@ -642,8 +643,13 @@ LIBBUTL_MODEXPORT namespace butl
// char[N]
//
- inline const char*
- process_arg_as (const char* s, std::string&) {return s;}
+ template <typename V>
+ inline void
+ process_args_as (V& v, const char* s, std::string&)
+ {
+ if (s != nullptr)
+ v.push_back (s);
+ }
template <std::size_t N>
inline const char*
@@ -699,7 +705,8 @@ LIBBUTL_MODEXPORT namespace butl
process_args_as (V& v, const std::vector<const char*>& vs, std::string&)
{
for (const char* s: vs)
- v.push_back (s);
+ if (s != nullptr)
+ v.push_back (s);
}
template <typename V, std::size_t N>
@@ -707,7 +714,8 @@ LIBBUTL_MODEXPORT namespace butl
process_args_as (V& v, const small_vector<const char*, N>& vs, std::string&)
{
for (const char* s: vs)
- v.push_back (s);
+ if (s != nullptr)
+ v.push_back (s);
}
template <typename V>
@@ -715,7 +723,8 @@ LIBBUTL_MODEXPORT namespace butl
process_args_as (V& v, const vector_view<const char*>& vs, std::string&)
{
for (const char* s: vs)
- v.push_back (s);
+ if (s != nullptr)
+ v.push_back (s);
}
}