From: Joel Rosdahl Date: Tue, 5 May 2020 12:58:07 +0000 (+0200) Subject: C++-ify parts of process_arg X-Git-Tag: v4.0~500 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f441bc13388c8e9b197d170a4ea127bb37b88d34;p=thirdparty%2Fccache.git C++-ify parts of process_arg --- diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp index f665f1359..29ca36cf8 100644 --- a/src/argprocessing.cpp +++ b/src/argprocessing.cpp @@ -183,8 +183,8 @@ process_profiling_option(Context& ctx, const std::string& arg) return true; } -// Compiler in depend mode is invoked with the original arguments. -// Collect extra arguments that should be added. +// Compiler in depend mode is invoked with the original arguments. Collect extra +// arguments that should be added. void add_extra_arg(Context& ctx, const std::string& arg) { @@ -208,23 +208,23 @@ process_arg(Context& ctx, const std::string& arg = args[i]; // The user knows best: just swallow the next arg. - if (str_eq(argv[i], "--ccache-skip")) { + if (args[i] == "--ccache-skip") { i++; - if (i == argc) { + if (i == args.size()) { cc_log("--ccache-skip lacks an argument"); return STATS_ARGS; } - args_add(state.common_args, argv[i]); + state.common_args.push_back(args[i]); return nullopt; } // Special case for -E. - if (str_eq(argv[i], "-E")) { + if (args[i] == "-E") { return STATS_PREPROCESSING; } // Handle "@file" argument. - if (str_startswith(argv[i], "@") || str_startswith(argv[i], "-@")) { + if (Util::starts_with(args[i], "@") || Util::starts_with(args[i], "-@")) { const char* argpath = argv[i] + 1; if (argpath[-1] == '-') { @@ -236,7 +236,7 @@ process_arg(Context& ctx, return STATS_ARGS; } - args_insert(args, i, *file_args, true); + args.replace(i, *file_args); i--; return nullopt; }