zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 76e2764eb1405eabe53b10bccdde7684432c4596 (tree)
parent dcddbcaa604d9228caddea7b2cd2668bf392149f
Author: Ryan Liptak <squeek502@hotmail.com>
Date:   Thu, 28 Aug 2025 04:20:35 -0700

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

Diffstat:
Msrc/main.zig | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main.zig b/src/main.zig @@ -1064,8 +1064,8 @@ fn buildOutputType( } } else if (mem.eql(u8, arg, "--dep")) { var it = mem.splitScalar(u8, args_iter.nextOrFatal(), '='); - const key = it.next().?; - const value = it.next() orelse key; + const key = it.first(); + const value = if (it.peek() != null) it.rest() else key; if (mem.eql(u8, key, "std") and !mem.eql(u8, value, "std")) { fatal("unable to import as '{s}': conflicts with builtin module", .{ key, @@ -1084,8 +1084,8 @@ fn buildOutputType( }); } else if (mem.startsWith(u8, arg, "-M")) { var it = mem.splitScalar(u8, arg["-M".len..], '='); - const mod_name = it.next().?; - const root_src_orig = it.next(); + const mod_name = it.first(); + const root_src_orig = if (it.peek() != null) it.rest() else null; try handleModArg( arena, mod_name,