From 5efc7faaea8fc780cf0fc9d0629fc50ea4fbd3b4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 7 Nov 2022 10:53:01 +0200 Subject: Tighten args const-ness in the run*() function family --- libbuild2/utility.hxx | 66 +++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 31 deletions(-) (limited to 'libbuild2/utility.hxx') diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx index a2259df..9f269bc 100644 --- a/libbuild2/utility.hxx +++ b/libbuild2/utility.hxx @@ -4,14 +4,15 @@ #ifndef LIBBUILD2_UTILITY_HXX #define LIBBUILD2_UTILITY_HXX -#include // make_tuple() -#include // make_shared() -#include // to_string() -#include // move(), forward(), declval(), make_pair(), swap() -#include // assert() -#include // make_move_iterator() -#include // * -#include // ref(), cref() +#include // make_tuple() +#include // make_shared() +#include // to_string() +#include // move(), forward(), declval(), make_pair(), swap() +#include // assert() +#include // make_move_iterator() +#include // * +#include // ref(), cref() +#include #include @@ -272,7 +273,7 @@ namespace build2 LIBBUILD2_SYMEXPORT process run_start (uint16_t verbosity, const process_env&, // Implicit-constructible from process_path. - const char* args[], + const char* const* args, int in = 0, int out = 1, process::pipe = {-1, 2}, @@ -281,7 +282,7 @@ namespace build2 inline process run_start (uint16_t verbosity, const process_env& pe, - cstrings& args, + const cstrings& args, int in = 0, int out = 1, process::pipe err = {-1, 2}, @@ -292,7 +293,7 @@ namespace build2 inline process run_start (const process_env& pe, - const char* args[], + const char* const* args, int in = 0, int out = 1, process::pipe err = {-1, 2}, @@ -303,7 +304,7 @@ namespace build2 inline process run_start (const process_env& pe, - cstrings& args, + const cstrings& args, int in = 0, int out = 1, process::pipe err = {-1, 2}, @@ -439,17 +440,17 @@ namespace build2 LIBBUILD2_SYMEXPORT void run (context&, const process_env& pe, // Implicit-constructible from process_path. - const char* args[]); + const char* const* args); LIBBUILD2_SYMEXPORT void run (diag_buffer&, const process_env& pe, - const char* args[]); + const char* const* args); inline void run (context& ctx, const process_env& pe, - cstrings& args) + const cstrings& args) { run (ctx, pe, args.data ()); } @@ -457,7 +458,7 @@ namespace build2 inline void run (diag_buffer& dbuf, const process_env& pe, - cstrings& args) + const cstrings& args) { run (dbuf, pe, args.data ()); } @@ -468,7 +469,7 @@ namespace build2 inline void run (context& ctx, const process_path& p, - const char* args[], + const char* const* args, const char* const* env, const dir_path& cwd = {}) { @@ -478,7 +479,7 @@ namespace build2 inline void run (diag_buffer& dbuf, const process_path& p, - const char* args[], + const char* const* args, const char* const* env, const dir_path& cwd = {}) { @@ -488,7 +489,7 @@ namespace build2 inline void run (context& ctx, const process_path& p, - cstrings& args, + const cstrings& args, const char* const* env, const dir_path& cwd = {}) { @@ -498,7 +499,7 @@ namespace build2 inline void run (diag_buffer& dbuf, const process_path& p, - cstrings& args, + const cstrings& args, const char* const* env, const dir_path& cwd = {}) { @@ -533,7 +534,7 @@ namespace build2 run (context&, uint16_t verbosity, const process_env&, // Implicit-constructible from process_path. - const char* args[], + const char* const* args, F&&, bool error = true, bool ignore_exit = false, @@ -544,7 +545,7 @@ namespace build2 run (context& ctx, uint16_t verbosity, const process_env& pe, - cstrings& args, + const cstrings& args, F&& f, bool error = true, bool ignore_exit = false, @@ -562,7 +563,7 @@ namespace build2 run (diag_buffer&, uint16_t verbosity, const process_env&, - const char* args[], + const char* const* args, F&&, bool ignore_exit = false, sha256* checksum = nullptr); @@ -572,7 +573,7 @@ namespace build2 run (diag_buffer& dbuf, uint16_t verbosity, const process_env& pe, - cstrings& args, + const cstrings& args, F&& f, bool ignore_exit = false, sha256* checksum = nullptr) @@ -588,7 +589,7 @@ namespace build2 inline T run (context& ctx, const process_env& pe, - const char* args[], + const char* const* args, F&& f, bool error = true, bool ignore_exit = false, @@ -605,7 +606,7 @@ namespace build2 inline T run (context& ctx, const process_env& pe, - cstrings& args, + const cstrings& args, F&& f, bool error = true, bool ignore_exit = false, @@ -621,7 +622,7 @@ namespace build2 inline T run (diag_buffer& dbuf, const process_env& pe, - const char* args[], + const char* const* args, F&& f, bool ignore_exit = false, sha256* checksum = nullptr) @@ -637,7 +638,7 @@ namespace build2 inline T run (diag_buffer& dbuf, const process_env& pe, - cstrings& args, + const cstrings& args, F&& f, bool ignore_exit = false, sha256* checksum = nullptr) @@ -739,7 +740,10 @@ namespace build2 } template - inline T + inline typename std::enable_if< + (!std::is_same::type, const char**>::value && + !std::is_same::type, cstrings>::value), + T>::type run (context& ctx, uint16_t verbosity, const process_env& pe, // Implicit-constructible from process_path. @@ -811,7 +815,7 @@ namespace build2 run (context&, uint16_t verbosity, const process_env&, - const char* args[], + const char* const* args, const function&, bool trim = true, bool err = true, @@ -822,7 +826,7 @@ namespace build2 run (diag_buffer& dbuf, uint16_t verbosity, const process_env&, - const char* args[], + const char* const* args, const function&, bool trim = true, bool ignore_exit = false, -- cgit v1.1