authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-08-28 04:20:35-07:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-09-02 22:35:01+02:00
log76e2764eb1405eabe53b10bccdde7684432c4596
tree9d767e581d7a01e6d07e93eaebccceab35ca744d
parentdcddbcaa604d9228caddea7b2cd2668bf392149f
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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
...@@ -1064,8 +1064,8 @@ fn buildOutputType(...@@ -1064,8 +1064,8 @@ fn buildOutputType(
1064 }1064 }
1065 } else if (mem.eql(u8, arg, "--dep")) {1065 } else if (mem.eql(u8, arg, "--dep")) {
1066 var it = mem.splitScalar(u8, args_iter.nextOrFatal(), '=');1066 var it = mem.splitScalar(u8, args_iter.nextOrFatal(), '=');
1067 const key = it.next().?;1067 const key = it.first();
1068 const value = it.next() orelse key;1068 const value = if (it.peek() != null) it.rest() else key;
1069 if (mem.eql(u8, key, "std") and !mem.eql(u8, value, "std")) {1069 if (mem.eql(u8, key, "std") and !mem.eql(u8, value, "std")) {
1070 fatal("unable to import as '{s}': conflicts with builtin module", .{1070 fatal("unable to import as '{s}': conflicts with builtin module", .{
1071 key,1071 key,
...@@ -1084,8 +1084,8 @@ fn buildOutputType(...@@ -1084,8 +1084,8 @@ fn buildOutputType(
1084 });1084 });
1085 } else if (mem.startsWith(u8, arg, "-M")) {1085 } else if (mem.startsWith(u8, arg, "-M")) {
1086 var it = mem.splitScalar(u8, arg["-M".len..], '=');1086 var it = mem.splitScalar(u8, arg["-M".len..], '=');
1087 const mod_name = it.next().?;1087 const mod_name = it.first();
1088 const root_src_orig = it.next();1088 const root_src_orig = if (it.peek() != null) it.rest() else null;
1089 try handleModArg(1089 try handleModArg(
1090 arena,1090 arena,
1091 mod_name,1091 mod_name,