]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
style: Improve names of Args::AtFileFormat values
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 14 May 2022 18:36:01 +0000 (20:36 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 14 May 2022 18:41:33 +0000 (20:41 +0200)
src/Args.cpp
src/Args.hpp
src/argprocessing.cpp
unittest/test_Args.cpp

index 6b4ec2183bbce889f6235168f4054b3c662b8510..09aa8482d517b852b3c8d0dc3579d2f46bb4daa4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2021 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2022 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -74,12 +74,12 @@ Args::from_atfile(const std::string& filename, AtFileFormat format)
     case '\\':
       pos++;
       switch (format) {
-      case AtFileFormat::QuoteAny_EscapeAny:
+      case AtFileFormat::gcc:
         if (*pos == '\0') {
           continue;
         }
         break;
-      case AtFileFormat::QuoteDouble_EscapeQuoteEscape:
+      case AtFileFormat::msvc:
         if (*pos != '"' && *pos != '\\') {
           pos--;
         }
@@ -88,7 +88,7 @@ Args::from_atfile(const std::string& filename, AtFileFormat format)
       break;
 
     case '\'':
-      if (format == AtFileFormat::QuoteDouble_EscapeQuoteEscape) {
+      if (format == AtFileFormat::msvc) {
         break;
       }
       // Fall through.
index 75aa331fe253e9ab592384ba54086e20087891a7..d55ecd41acafdae4d1f86356c4c67607209c441a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2021 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2022 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
 class Args
 {
 public:
+  enum class AtFileFormat {
+    gcc,  // '\'' and '"' quote, '\\' escapes any character
+    msvc, // '"' quotes, '\\' escapes only '"' and '\\'
+  };
+
   Args() = default;
   Args(const Args& other) = default;
   Args(Args&& other) noexcept;
@@ -37,13 +42,9 @@ public:
   static Args from_argv(int argc, const char* const* argv);
   static Args from_string(const std::string& command);
 
-  enum class AtFileFormat {
-    QuoteAny_EscapeAny, // '\'' and '"' quote, '\\' escapes any character
-    QuoteDouble_EscapeQuoteEscape, // '"' quotes, '\\' escapes only '"' and '\\'
-  };
   static nonstd::optional<Args>
   from_atfile(const std::string& filename,
-              AtFileFormat format = AtFileFormat::QuoteAny_EscapeAny);
+              AtFileFormat format = AtFileFormat::gcc);
 
   Args& operator=(const Args& other) = default;
   Args& operator=(Args&& other) noexcept;
index 679ee101ec2f2829ed7b11afc541062ababb7015..cc4040d729988c66e74eca5b2157a85d5c8ca81c 100644 (file)
@@ -306,11 +306,10 @@ process_arg(const Context& ctx,
     if (argpath[-1] == '-') {
       ++argpath;
     }
-    auto file_args =
-      Args::from_atfile(argpath,
-                        config.is_compiler_group_msvc()
-                          ? Args::AtFileFormat::QuoteDouble_EscapeQuoteEscape
-                          : Args::AtFileFormat::QuoteAny_EscapeAny);
+    auto file_args = Args::from_atfile(argpath,
+                                       config.is_compiler_group_msvc()
+                                         ? Args::AtFileFormat::msvc
+                                         : Args::AtFileFormat::gcc);
     if (!file_args) {
       LOG("Couldn't read arg file {}", argpath);
       return Statistic::bad_compiler_arguments;
index ee9f80831f63f93f3bcd9fc7001fd10b83ba6978..db656079c4ac219471777f1cfb1bed101dbabb66 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2022 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -140,8 +140,7 @@ TEST_CASE("Args::from_atfile")
   SUBCASE("Only escape double quote and backslash in alternate format")
   {
     Util::write_file("at_file", "\"\\\"\\a\\ \\\\\\ \\b\\\"\"\\");
-    args = *Args::from_atfile(
-      "at_file", Args::AtFileFormat::QuoteDouble_EscapeQuoteEscape);
+    args = *Args::from_atfile("at_file", Args::AtFileFormat::msvc);
     CHECK(args.size() == 1);
     CHECK(args[0] == "\"\\a\\ \\\\ \\b\"\\");
   }
@@ -149,8 +148,7 @@ TEST_CASE("Args::from_atfile")
   SUBCASE("Ignore single quote in alternate format")
   {
     Util::write_file("at_file", "'a b'");
-    args = *Args::from_atfile(
-      "at_file", Args::AtFileFormat::QuoteDouble_EscapeQuoteEscape);
+    args = *Args::from_atfile("at_file", Args::AtFileFormat::msvc);
     CHECK(args.size() == 2);
     CHECK(args[0] == "'a");
     CHECK(args[1] == "b'");