From 822059e4e69547f8e97a1cd219912f55826b0414 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 27 Jul 2017 18:00:16 +0300 Subject: Rename process_start() and process_run() overloads --- libbutl/curl.hxx | 3 ++- libbutl/curl.txx | 2 +- libbutl/openssl.hxx | 3 ++- libbutl/openssl.txx | 18 ++++++------- libbutl/process-run.txx | 60 ++++++++++++++++++++++---------------------- libbutl/process.hxx | 26 +++++++++---------- libbutl/sendmail.hxx | 3 ++- libbutl/sendmail.ixx | 16 ++++++------ tests/process-run/driver.cxx | 16 ++++++------ tests/progress/driver.cxx | 10 +++++--- 10 files changed, 82 insertions(+), 75 deletions(-) diff --git a/libbutl/curl.hxx b/libbutl/curl.hxx index 19105ef..dad0bf5 100644 --- a/libbutl/curl.hxx +++ b/libbutl/curl.hxx @@ -105,7 +105,8 @@ namespace butl const std::string& url, A&&... options); - // Version with the command line callback (see process_run() for details). + // Version with the command line callback (see process_run_callback() for + // details). // template (in), mp, in_data), map_out (std::forward (out), mp, out_data), diff --git a/libbutl/openssl.hxx b/libbutl/openssl.hxx index bd562d6..9ab248c 100644 --- a/libbutl/openssl.hxx +++ b/libbutl/openssl.hxx @@ -96,7 +96,8 @@ namespace butl const std::string& command, A&&... options); - // Version with the command line callback (see process_run() for details). + // Version with the command line callback (see process_run_callback() for + // details). // template (in), in_data), - map_out (std::forward (out), out_data), - std::forward (err), - env, - command, - in_data.options, - out_data.options, - std::forward (options)...); + p = process_start_callback (cmdc, + map_in (std::forward (in), in_data), + map_out (std::forward (out), out_data), + std::forward (err), + env, + command, + in_data.options, + out_data.options, + std::forward (options)...); // Note: leaving this scope closes any open ends of the pipes in io_data. } diff --git a/libbutl/process-run.txx b/libbutl/process-run.txx index a78b87a..a9c7e8b 100644 --- a/libbutl/process-run.txx +++ b/libbutl/process-run.txx @@ -108,12 +108,12 @@ namespace butl typename E, typename... A> inline process - process_start (const C& cmdc, - I&& in, - O&& out, - E&& err, - const process_env& env, - A&&... args) + process_start_callback (const C& cmdc, + I&& in, + O&& out, + E&& err, + const process_env& env, + A&&... args) { return process_start (std::index_sequence_for (), cmdc, @@ -135,12 +135,12 @@ namespace butl const process_env& env, A&&... args) { - return process_start ([] (const char* [], std::size_t) {}, - std::forward (in), - std::forward (out), - std::forward (err), - env, - std::forward (args)...); + return process_start_callback ([] (const char* [], std::size_t) {}, + std::forward (in), + std::forward (out), + std::forward (err), + env, + std::forward (args)...); } template inline process_exit - process_run (const C& cmdc, - I&& in, - O&& out, - E&& err, - const process_env& env, - A&&... args) + process_run_callback (const C& cmdc, + I&& in, + O&& out, + E&& err, + const process_env& env, + A&&... args) { process pr ( - process_start (cmdc, - std::forward (in), - std::forward (out), - std::forward (err), - env, - std::forward (args)...)); + process_start_callback (cmdc, + std::forward (in), + std::forward (out), + std::forward (err), + env, + std::forward (args)...)); pr.wait (); return *pr.exit; @@ -179,11 +179,11 @@ namespace butl const process_env& env, A&&... args) { - return process_run ([] (const char* [], std::size_t) {}, - std::forward (in), - std::forward (out), - std::forward (err), - env, - std::forward (args)...); + return process_run_callback ([] (const char* [], std::size_t) {}, + std::forward (in), + std::forward (out), + std::forward (err), + env, + std::forward (args)...); } } diff --git a/libbutl/process.hxx b/libbutl/process.hxx index ee17207..cd692ca 100644 --- a/libbutl/process.hxx +++ b/libbutl/process.hxx @@ -397,7 +397,7 @@ namespace butl // read from /dev/null, stdout redirect to stderr, and inherit the parent's // stderr. // - // process_run (..., fdnull (), 2, 2, ...) + // process_run (fdnull (), 2, 2, ...) // // The P argument is the program path. It can be anything that can be passed // to process::path_search() (const char*, std::string, path) or the @@ -504,12 +504,12 @@ namespace butl typename E, typename... A> process_exit - process_run (const C&, - I&& in, - O&& out, - E&& err, - const process_env&, - A&&... args); + process_run_callback (const C&, + I&& in, + O&& out, + E&& err, + const process_env&, + A&&... args); // Versions that start the process without waiting. // @@ -530,12 +530,12 @@ namespace butl typename E, typename... A> process - process_start (const C&, - I&& in, - O&& out, - E&& err, - const process_env&, - A&&... args); + process_start_callback (const C&, + I&& in, + O&& out, + E&& err, + const process_env&, + A&&... args); // Conversion of types to their C string representations. Can be overloaded // (including via ADL) for custom types. The default implementation calls diff --git a/libbutl/sendmail.hxx b/libbutl/sendmail.hxx index 465a474..c631f18 100644 --- a/libbutl/sendmail.hxx +++ b/libbutl/sendmail.hxx @@ -77,7 +77,8 @@ namespace butl const recipients_type& bcc, O&&... options); - // Version with the command line callback (see process_run() for details). + // Version with the command line callback (see process_run_callback() for + // details). // template sendmail (const C&, diff --git a/libbutl/sendmail.ixx b/libbutl/sendmail.ixx index 72d3d45..36c0530 100644 --- a/libbutl/sendmail.ixx +++ b/libbutl/sendmail.ixx @@ -62,14 +62,14 @@ namespace butl fdpipe pipe (fdopen_pipe ()); // Text mode seems appropriate. process& p (*this); - p = process_start (cmdc, - pipe.in, - 2, // No output expected so redirect to stderr. - std::forward (err), - "sendmail", - "-i", // Don't treat '.' as the end of input. - "-t", // Read recipients from headers. - std::forward (options)...); + p = process_start_callback (cmdc, + pipe.in, + 2, // No output expected so redirect to stderr. + std::forward (err), + "sendmail", + "-i", // Don't treat '.' as the end of input. + "-t", // Read recipients from headers. + std::forward (options)...); // Close the reading end of the pipe not to block on writing if sendmail // terminates before that. diff --git a/tests/process-run/driver.cxx b/tests/process-run/driver.cxx index ff9dd25..695fdb9 100644 --- a/tests/process-run/driver.cxx +++ b/tests/process-run/driver.cxx @@ -65,14 +65,14 @@ main (int argc, const char* argv[]) assert (run (0, 1, 2, p)); assert (run (0, 1, 2, p, "-c")); - process_run ([] (const char* c[], size_t n) - { - process::print (cout, c, n); - cout << endl; - }, - 0, 1, 2, - p, - "-c"); + process_run_callback ([] (const char* c[], size_t n) + { + process::print (cout, c, n); + cout << endl; + }, + 0, 1, 2, + p, + "-c"); // Stream conversion and redirection. // diff --git a/tests/progress/driver.cxx b/tests/progress/driver.cxx index 64e84fd..791e485 100644 --- a/tests/progress/driver.cxx +++ b/tests/progress/driver.cxx @@ -70,10 +70,14 @@ main (int argc, const char* argv[]) auto print = [] (const string& s) { #ifndef _WIN32 - write (stderr_fd(), s.c_str (), s.size ()); + ssize_t r (write (stderr_fd(), s.c_str (), s.size ())); #else - _write (stderr_fd(), s.c_str (), static_cast (s.size ())); + int r (_write (stderr_fd(), + s.c_str (), + static_cast (s.size ()))); #endif + + assert (r != -1); }; for (size_t i (50); i != 0; --i) @@ -89,7 +93,7 @@ main (int argc, const char* argv[]) // warns about calls ambiguity). // process pr (!no_child - ? process_start (fdnull (), fdnull (), stderr_fd (), + ? process_start (fdnull (), fdnull (), 2, process_env (argv[0]), "-c") : process (process_exit (0))); // Exited normally. -- cgit v1.1