From 2716772d9896ad7505b05785c96f33f2fba73bd9 Mon Sep 17 00:00:00 2001 From: Peter Li Date: Sun, 1 Nov 2026 20:16:21 -0800 Subject: [PATCH] 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. --- src/options.zig | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/options.zig b/src/options.zig index 0f0a768..e91fdde 100644 --- a/src/options.zig +++ b/src/options.zig @@ -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;