diff options
author | Julien Dessaux | 2022-08-15 19:24:34 +0200 |
---|---|---|
committer | Julien Dessaux | 2022-08-16 19:24:34 +0200 |
commit | 357c54663c332aff82f539a838a930842192e5ba (patch) | |
tree | 9a7bd759aaa9c3741a14f5ee5e3d6f21807d1ce1 | |
parent | Implemented the y command (diff) | |
download | zigfunge98-357c54663c332aff82f539a838a930842192e5ba.tar.gz zigfunge98-357c54663c332aff82f539a838a930842192e5ba.tar.bz2 zigfunge98-357c54663c332aff82f539a838a930842192e5ba.zip |
Fixed bugs reported by the mycology test suite
-rw-r--r-- | src/field.zig | 2 | ||||
-rw-r--r-- | src/main.zig | 2 | ||||
-rw-r--r-- | src/stack.zig | 5 |
3 files changed, 4 insertions, 5 deletions
diff --git a/src/field.zig b/src/field.zig index 9a12a80..6c0e420 100644 --- a/src/field.zig +++ b/src/field.zig @@ -287,7 +287,7 @@ pub const Field = struct { } } switch (buffer[i]) { - 12 => x += 1, + 12 => continue, '\r' => { x = 0; y += 1; diff --git a/src/main.zig b/src/main.zig index d1b6ccb..1608b87 100644 --- a/src/main.zig +++ b/src/main.zig @@ -12,7 +12,7 @@ pub fn main() anyerror!void { std.os.exit(1); } - var file = try std.fs.cwd().openFile("mycology/sanity.bf", .{}); + var file = try std.fs.cwd().openFile(args[1], .{}); defer file.close(); const env: []const [*:0]const u8 = std.os.environ; diff --git a/src/stack.zig b/src/stack.zig index 09edd2e..c1f8696 100644 --- a/src/stack.zig +++ b/src/stack.zig @@ -12,9 +12,8 @@ pub const Stack = struct { self.allocator.destroy(self); } pub fn duplicate(self: *Stack) !void { - if (self.data.items.len > 0) { - try self.push(self.data.items[self.data.items.len - 1]); - } + const v = self.pop(); + try self.pushVector([2]i64{ v, v }); } test "duplicate" { var s = try Stack.init(std.testing.allocator); |