diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2024-12-11 19:15:18 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2024-12-11 21:48:37 +0100 |
commit | e166206702c8dbd3162452cf26f368e856ac0138 (patch) | |
tree | e4e659fc91b0a47f04755b6298b8085370aefc8d /src/configure.cc | |
parent | 936fb83eec4038a48e6e42f9f5d93677dc216ab4 (diff) |
More clang-tidy fixes and increase warning level (and fix them)
Diffstat (limited to 'src/configure.cc')
-rw-r--r-- | src/configure.cc | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/configure.cc b/src/configure.cc index 26d3575..995e340 100644 --- a/src/configure.cc +++ b/src/configure.cc @@ -7,6 +7,7 @@ #include <filesystem> #include <fstream> #include <optional> +#include <span> #include <getoptpp/getoptpp.hpp> @@ -321,19 +322,19 @@ int regenerateCache(ctor::settings& settings, } auto add_path_args = - [&](const std::string& name) + [&](const std::string& arg_name) { - opt.add(name + "-includedir", required_argument, key++, - "Set path to " + name + " header file.", + opt.add(arg_name + "-includedir", required_argument, key++, + "Set path to " + arg_name + " header file.", [&]() { - external_includedir[name] = optarg; + external_includedir[arg_name] = optarg; return 0; }); - opt.add(name + "-libdir", required_argument, key++, - "Set path to " + name + " libraries.", + opt.add(arg_name + "-libdir", required_argument, key++, + "Set path to " + arg_name + " libraries.", [&]() { - external_libdir[name] = optarg; + external_libdir[arg_name] = optarg; return 0; }); }; @@ -366,7 +367,7 @@ int regenerateCache(ctor::settings& settings, return 0; }); - opt.process(vargs.size(), vargs.data()); + opt.process(static_cast<int>(vargs.size()), vargs.data()); if(host_arch_prefix.empty()) { @@ -821,12 +822,14 @@ int regenerateCache(ctor::settings& settings, int configure(const ctor::settings& global_settings, int argc, char* argv[]) { + auto args_span = std::span(argv, static_cast<std::size_t>(argc)); + ctor::settings settings{global_settings}; std::vector<std::string> args; - for(int i = 2; i < argc; ++i) // skip command and the first 'configure' arg + for(std::size_t i = 2; i < args_span.size(); ++i) // skip command and the first 'configure' arg { - args.emplace_back(argv[i]); + args.emplace_back(args_span[i]); } std::map<std::string, std::string> env; @@ -860,7 +863,7 @@ int configure(const ctor::settings& global_settings, int argc, char* argv[]) env["PATH"] = path_env; } - auto ret = regenerateCache(settings, argv[0], args, env); + auto ret = regenerateCache(settings, args_span[0], args, env); if(ret != 0) { return ret; @@ -873,19 +876,21 @@ int configure(const ctor::settings& global_settings, int argc, char* argv[]) int reconfigure(const ctor::settings& global_settings, int argc, char* argv[]) { + auto args_span = std::span(argv, static_cast<std::size_t>(argc)); + ctor::settings settings{global_settings}; bool no_rerun{false}; std::vector<std::string> args; - for(int i = 2; i < argc; ++i) // skip executable name and 'reconfigure' arg + for(std::size_t i = 2; i < args_span.size(); ++i) // skip executable name and 'reconfigure' arg { - if(i == 2 && std::string(argv[i]) == "--no-rerun") + if(i == 2 && std::string(args_span[i]) == "--no-rerun") { no_rerun = true; continue; } - args.emplace_back(argv[i]); + args.emplace_back(args_span[i]); } const auto& cfg = ctor::get_configuration(); @@ -895,14 +900,14 @@ int reconfigure(const ctor::settings& global_settings, int argc, char* argv[]) { std::cout << e.first << "=\"" << e.second << "\" "; } - std::cout << argv[0] << " configure "; + std::cout << args_span[0] << " configure "; for(const auto& arg : cfg.args) { std::cout << arg << " "; } std::cout << "\n"; - auto ret = regenerateCache(settings, argv[0], cfg.args, cfg.env); + auto ret = regenerateCache(settings, args_span[0], cfg.args, cfg.env); if(ret != 0) { return ret; @@ -915,5 +920,5 @@ int reconfigure(const ctor::settings& global_settings, int argc, char* argv[]) return 0; // this was originally invoked by configure, don't loop } - return execute(settings, argv[0], args); + return execute(settings, args_span[0], args); } |