From d6c92c0231aeb8db3f756616180f50c8438dc002 Mon Sep 17 00:00:00 2001 From: Luna Date: Tue, 2 Jun 2020 16:00:54 -0300 Subject: [PATCH 1/4] add split and index when printing custom/lv2 cmds --- src/printer.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/printer.zig b/src/printer.zig index 2302cfc..bf32f76 100644 --- a/src/printer.zig +++ b/src/printer.zig @@ -3,6 +3,7 @@ const langs = @import("lang.zig"); fn printCommandWithParams(stream: var, command: var) !void { const Parameters = @TypeOf(command.parameters); + try stream.print(" {} {}", .{ command.split, command.index }); inline for (@typeInfo(Parameters).Struct.fields) |field| { if (field.field_type == f32 or field.field_type == f64) { try stream.print(" {d}", .{@field(command.parameters, field.name)}); From 0240b10a3c4d934644ffaf04e1ecc65d97caa4bf Mon Sep 17 00:00:00 2001 From: Luna Date: Tue, 2 Jun 2020 16:11:30 -0300 Subject: [PATCH 2/4] close handles while making temporary paths --- src/image.zig | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/image.zig b/src/image.zig index b9202ef..ef27b7a 100644 --- a/src/image.zig +++ b/src/image.zig @@ -95,12 +95,16 @@ pub fn temporaryName(allocator: *std.mem.Allocator) ![]u8 { } // if we fail to access it, we assume it doesn't exist and return it. - - _ = std.fs.cwd().openFile(nam, .{ .read = true, .write = false }) catch |err| { - if (err == error.FileNotFound) { - return nam; - } + var tmp_file: std.fs.File = std.fs.cwd().openFile( + nam, + .{ .read = true, .write = false }, + ) catch |err| blk: { + if (err == error.FileNotFound) return nam else continue; }; + + // if we actually found someone, close the handle so that we don't + // get EMFILE later on. + tmp_file.close(); } return error.TempGenFail; From c7eb70a06f083cfafb0c23feeaf6d25992ab481e Mon Sep 17 00:00:00 2001 From: Luna Date: Tue, 2 Jun 2020 16:16:43 -0300 Subject: [PATCH 3/4] ignore lines without commands --- src/main.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.zig b/src/main.zig index a2716d7..4a65230 100644 --- a/src/main.zig +++ b/src/main.zig @@ -208,6 +208,10 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void { std.debug.warn("repl: error while parsing: {}\n", .{err}); continue; }; + + // no command? ignore! + if (cmds_parsed.items.len == 0) continue; + current = cmds_parsed.items[0].*; // by cloning the parent runner, we can iteratively write From 542ba75b01638751b9ddb2ea6fd94c287fbd3de5 Mon Sep 17 00:00:00 2001 From: Luna Date: Tue, 2 Jun 2020 16:16:49 -0300 Subject: [PATCH 4/4] make repl cloned runner run the runqs cmd --- src/main.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index 4a65230..7d6cc00 100644 --- a/src/main.zig +++ b/src/main.zig @@ -224,7 +224,7 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void { // of this function. try cmds.append(&runqs_cmd.base); - try runner_clone.runCommands(cmds_parsed, true); + try runner_clone.runCommands(cmds, true); _ = try stdout.write("\n"); } }