authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-08-28 04:20:35-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-31 19:32:07-07:00
logbc7955306e3480fc065277d0b6c5abb6797a27ae
tree1c3203bc48543fdb26c0d4608ceddebf033b7be2
parent1ec8a7ab4c5346839ee9aa002aadee91d72903fe

Fix `-M` and `--dep` splitting on every = instead of just the first

Before this commit, -Mfoo=bar=baz would be incorrectly split into mod_name: `foo` and root_src_orig: `bar` After this commit, -Mfoo=bar=baz will be correctly split into mod_name: `foo` and root_src_orig: `bar=baz` Closes #25059

1 files changed, 4 insertions(+), 4 deletions(-)

src/main.zig+4-4
...@@ -1060,8 +1060,8 @@ fn buildOutputType(...@@ -1060,8 +1060,8 @@ fn buildOutputType(
1060 }1060 }
1061 } else if (mem.eql(u8, arg, "--dep")) {1061 } else if (mem.eql(u8, arg, "--dep")) {
1062 var it = mem.splitScalar(u8, args_iter.nextOrFatal(), '=');1062 var it = mem.splitScalar(u8, args_iter.nextOrFatal(), '=');
1063 const key = it.next().?;1063 const key = it.first();
1064 const value = it.next() orelse key;1064 const value = if (it.peek() != null) it.rest() else key;
1065 if (mem.eql(u8, key, "std") and !mem.eql(u8, value, "std")) {1065 if (mem.eql(u8, key, "std") and !mem.eql(u8, value, "std")) {
1066 fatal("unable to import as '{s}': conflicts with builtin module", .{1066 fatal("unable to import as '{s}': conflicts with builtin module", .{
1067 key,1067 key,
...@@ -1080,8 +1080,8 @@ fn buildOutputType(...@@ -1080,8 +1080,8 @@ fn buildOutputType(
1080 });1080 });
1081 } else if (mem.startsWith(u8, arg, "-M")) {1081 } else if (mem.startsWith(u8, arg, "-M")) {
1082 var it = mem.splitScalar(u8, arg["-M".len..], '=');1082 var it = mem.splitScalar(u8, arg["-M".len..], '=');
1083 const mod_name = it.next().?;1083 const mod_name = it.first();
1084 const root_src_orig = it.next();1084 const root_src_orig = if (it.peek() != null) it.rest() else null;
1085 try handleModArg(1085 try handleModArg(
1086 arena,1086 arena,
1087 mod_name,1087 mod_name,