-// 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.
//
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--;
}
break;
case '\'':
- if (format == AtFileFormat::QuoteDouble_EscapeQuoteEscape) {
+ if (format == AtFileFormat::msvc) {
break;
}
// Fall through.
-// 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;
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;
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;
-// 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.
//
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\"\\");
}
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'");