Accept "-opt value" passed as one argument

dxc's option parser skips spaces after an option name, so a separate
option given as "-HV 2021" in a single argument is "-HV" with value
2021 (programs calling IDxcCompiler3::Compile pass it that way).
zdxc rejected it as an unknown argument. "-HV2021" stays an error, as
in dxc.
This commit is contained in:
Peter Li 2026-11-01 20:16:21 -08:00
parent c6d58c0017
commit 2716772d98
1 changed files with 7 additions and 3 deletions

View File

@ -168,10 +168,14 @@ fn parseOne(arena: Allocator, argv: []const []const u8, index: *usize, failure:
return .{ .which = c.which, .spelling = spelling, .values = vals.items };
},
.separate, .joined_or_separate => {
if (rest.len != 0) {
if (c.kind == .separate) continue;
// dxc also takes "-opt value" passed as one argument: spaces
// after the name are skipped, and all-space rest means the
// value is the next argument.
const value = std.mem.trimStart(u8, rest, " ");
if (value.len != 0) {
if (c.kind == .separate and value.len == rest.len) continue;
index.* += 1;
return .{ .which = c.which, .spelling = spelling, .values = try dupeOne(arena, rest) };
return .{ .which = c.which, .spelling = spelling, .values = try dupeOne(arena, value) };
}
if (index.* + 1 >= argv.len) {
failure.arg = spelling;