]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
C++-ify parts of process_arg
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 5 May 2020 12:58:07 +0000 (14:58 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 5 May 2020 18:25:58 +0000 (20:25 +0200)
src/argprocessing.cpp

index f665f135958edd98da343ff4728aeba15a0825fd..29ca36cf86afb554a838d74a22e24c9ed0bc1945 100644 (file)
@@ -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;
   }