From 84d582cfd1c2a582cbad2800da5c0a1397899e04 Mon Sep 17 00:00:00 2001 From: Luna Date: Tue, 10 Sep 2019 21:35:22 -0300 Subject: [PATCH] image: open curpath instead of path when cloning --- src/image.zig | 2 +- src/main.zig | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/image.zig b/src/image.zig index 1942f87..fdad5ca 100644 --- a/src/image.zig +++ b/src/image.zig @@ -151,7 +151,7 @@ pub const Image = struct { pub fn clone(self: *Image) !*Image { var in_fmt = mkSfInfo(); // clone sndfile - var sndfile = try sopen(self.allocator, self.path, c.SFM_READ, &in_fmt); + var sndfile = try sopen(self.allocator, self.curpath, c.SFM_READ, &in_fmt); var image = try allocator.create(Image); std.debug.assert(in_fmt.frames > i64(0)); diff --git a/src/main.zig b/src/main.zig index be83ad6..011256d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -75,10 +75,13 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void { if (std.mem.eql(u8, line, "push")) { try cmds.append(current); + + // run the current added command to main cmds list + // with the main parent runner var cmds_wrapped = try wrapInCmdList(allocator, current); defer cmds_wrapped.deinit(); - try runner.runCommands(cmds_wrapped, true); + continue; } else if (std.mem.eql(u8, line, "list")) { try printer.printList(cmds, stdout); @@ -95,6 +98,9 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void { }; current = cmds_parsed.at(0); + // by cloning the parent runner, we can iteratively write + // whatever command we want and only commit the good results + // back to the parent runner var runner_clone = try runner.clone(); defer runner_clone.deinit();