From b4d067adbe246549ae5b6cdac209d1d6ad4b600a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 23 Feb 2023 09:50:53 +0200 Subject: [PATCH] launcher: support multi-for loop syntax At the moment we need both old and new zig, so doing a way that's compatible with both. --- toolchain/launcher.zig | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/toolchain/launcher.zig b/toolchain/launcher.zig index b2a907a..23cb768 100644 --- a/toolchain/launcher.zig +++ b/toolchain/launcher.zig @@ -252,9 +252,15 @@ fn shouldReturnEarly(args: []const []const u8) bool { const prelude = comptimeSplit("-Wl,--no-gc-sections -x c - -o /dev/null"); if (args.len < prelude.len) return false; - for (prelude) |arg, i| + + // TODO: replace with: + // for (prelude, 0..) |arg, i| + var i: usize = 0; + for (prelude) |arg| { if (!mem.eql(u8, arg, args[args.len - prelude.len + i])) return false; + i += 1; + } return true; } @@ -336,8 +342,13 @@ fn compareExec( ) !void { try testing.expectEqual(want_args.len, res.exec.args.items.len); - for (want_args) |want_arg, i| + // TODO: replace with: + // for (prelude, 0..) |arg, i| + var i: usize = 0; + for (want_args) |want_arg| { try testing.expectEqualStrings(want_arg, res.exec.args.items[i]); + i += 1; + } try testing.expectEqualStrings( want_env_zig_lib_dir,