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/bin/def-rule.cxx | 3 -- libbuild2/cc/compile-rule.cxx | 4 --- libbuild2/cc/link-rule.cxx | 4 --- libbuild2/in/rule.cxx | 3 -- libbuild2/utility.cxx | 10 +++---- libbuild2/utility.hxx | 66 +++++++++++++++++++++++-------------------- libbuild2/utility.ixx | 4 +-- 7 files changed, 42 insertions(+), 52 deletions(-) diff --git a/libbuild2/bin/def-rule.cxx b/libbuild2/bin/def-rule.cxx index 5eeff4a..d887be7 100644 --- a/libbuild2/bin/def-rule.cxx +++ b/libbuild2/bin/def-rule.cxx @@ -835,9 +835,6 @@ namespace build2 return target_state::changed; } - // @@ TODO: split into rule_name (string) and rule_version (integer) - // on next increment. - // const string def_rule::rule_id_ {"bin.def 2"}; } } diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index 70f67bc..7ccaeb4 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -265,10 +265,6 @@ namespace build2 compile_rule:: compile_rule (data&& d, const scope& rs) : common (move (d)), - // - // @@ TODO: split into rule_name (string) and rule_version (integer) - // on next increment. - // rule_id (string (x) += ".compile 6") { // Locate the header cache (see enter_header() for details). diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index ff03fd9..af04ac7 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -254,10 +254,6 @@ namespace build2 link_rule:: link_rule (data&& d) : common (move (d)), - // - // @@ TODO: split into rule_name (string) and rule_version (integer) - // on next increment. - // rule_id (string (x) += ".link 3") { } diff --git a/libbuild2/in/rule.cxx b/libbuild2/in/rule.cxx index 761a882..d07adfc 100644 --- a/libbuild2/in/rule.cxx +++ b/libbuild2/in/rule.cxx @@ -147,9 +147,6 @@ namespace build2 // First should come the rule name/version. // - // @@ TODO: split into rule_name (string) and rule_version (integer) - // on next increment. - // if (dd.expect (rule_id_ + " 1") != nullptr) l4 ([&]{trace << "rule mismatch forcing update of " << t;}); diff --git a/libbuild2/utility.cxx b/libbuild2/utility.cxx index 68f54b9..556c4a3 100644 --- a/libbuild2/utility.cxx +++ b/libbuild2/utility.cxx @@ -215,7 +215,7 @@ namespace build2 process run_start (uint16_t verbosity, const process_env& pe, - const char* args[], + const char* const* args, int in, int out, process::pipe err, @@ -348,7 +348,7 @@ namespace build2 } void - run (context& ctx, const process_env& pe, const char* args[]) + run (context& ctx, const process_env& pe, const char* const* args) { if (ctx.phase == run_phase::load) { @@ -363,7 +363,7 @@ namespace build2 } void - run (diag_buffer& dbuf, const process_env& pe, const char* args[]) + run (diag_buffer& dbuf, const process_env& pe, const char* const* args) { process pr (run_start (pe, args, @@ -378,7 +378,7 @@ namespace build2 run (context& ctx, uint16_t verbosity, const process_env& pe, - const char* args[], + const char* const* args, const function& f, bool tr, bool err, @@ -448,7 +448,7 @@ namespace build2 run (diag_buffer& dbuf, uint16_t verbosity, const process_env& pe, - const char* args[], + const char* const* args, const function& f, bool tr, bool ignore_exit, 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, diff --git a/libbuild2/utility.ixx b/libbuild2/utility.ixx index f4b8152..c122ec9 100644 --- a/libbuild2/utility.ixx +++ b/libbuild2/utility.ixx @@ -103,7 +103,7 @@ namespace build2 run (context& ctx, uint16_t verbosity, const process_env& pe, - const char* args[], + const char* const* args, F&& f, bool err, bool ignore_exit, @@ -132,7 +132,7 @@ namespace build2 run (diag_buffer& dbuf, uint16_t verbosity, const process_env& pe, - const char* args[], + const char* const* args, F&& f, bool ignore_exit, sha256* checksum) -- cgit v1.1