From ec980d58a02151b3f39508be69d4ffea588b0850 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sun, 18 Sep 2022 00:53:23 -0700 Subject: [PATCH] remove dependence on non-const temporaries --- src/cmd/fetch.zig | 6 ++++-- src/cmd/generate.zig | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cmd/fetch.zig b/src/cmd/fetch.zig index c80a9b9277aca5d917501bb8ff5dacab83bf0c5d..495a42947368a2bf7226554b105227261bd3f6d2 100644 --- a/src/cmd/fetch.zig +++ b/src/cmd/fetch.zig @@ -109,13 +109,14 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D try w.writeAll("pub const package_data = struct {\n"); var duped = std.ArrayList(zigmod.Module).init(alloc); + var done = std.ArrayList(zigmod.Module).init(alloc); for (list.items) |mod| { if (mod.type == .system_lib or mod.type == .framework) { continue; } try duped.append(mod); } - try print_pkg_data_to(w, &duped, &std.ArrayList(zigmod.Module).init(alloc)); + try print_pkg_data_to(w, &duped, &done); try w.writeAll("};\n\n"); try w.writeAll("pub const packages = "); @@ -159,7 +160,8 @@ fn diff_lockfile(alloc: std.mem.Allocator) !void { if (try u.does_folder_exist(".git")) { const result = try u.run_cmd_raw(alloc, null, &.{ "git", "diff", "zigmod.lock" }); - const r = std.io.fixedBufferStream(result.stdout).reader(); + var stdout = std.io.fixedBufferStream(result.stdout); + const r = stdout.reader(); while (try r.readUntilDelimiterOrEofAlloc(alloc, '\n', max)) |line| { if (std.mem.startsWith(u8, line, "@@")) break; } diff --git a/src/cmd/generate.zig b/src/cmd/generate.zig index 0a8078ae42791ea148ef9a483746935df4ee3eeb..eeaf80bc34e1a7b6e914c70004f3be237a41b1e8 100644 --- a/src/cmd/generate.zig +++ b/src/cmd/generate.zig @@ -189,13 +189,14 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D try w.writeAll("pub const package_data = struct {\n"); var duped = std.ArrayList(zigmod.Module).init(alloc); + var done = std.ArrayList(zigmod.Module).init(alloc); for (list) |mod| { if (mod.type == .system_lib or mod.type == .framework) { continue; } try duped.append(mod); } - try print_pkg_data_to(w, alloc, cachepath, &duped, &std.ArrayList(zigmod.Module).init(alloc)); + try print_pkg_data_to(w, alloc, cachepath, &duped, &done); try w.writeAll("};\n\n"); try w.writeAll("pub const packages = "); -- 2.54.0