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:
parent
c6d58c0017
commit
2716772d98
|
|
@ -168,10 +168,14 @@ fn parseOne(arena: Allocator, argv: []const []const u8, index: *usize, failure:
|
||||||
return .{ .which = c.which, .spelling = spelling, .values = vals.items };
|
return .{ .which = c.which, .spelling = spelling, .values = vals.items };
|
||||||
},
|
},
|
||||||
.separate, .joined_or_separate => {
|
.separate, .joined_or_separate => {
|
||||||
if (rest.len != 0) {
|
// dxc also takes "-opt value" passed as one argument: spaces
|
||||||
if (c.kind == .separate) continue;
|
// 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;
|
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) {
|
if (index.* + 1 >= argv.len) {
|
||||||
failure.arg = spelling;
|
failure.arg = spelling;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue