diff options
Diffstat (limited to 'synth.zig')
| -rw-r--r-- | synth.zig | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/synth.zig b/synth.zig index 4e74cd8..3e04407 100644 --- a/synth.zig +++ b/synth.zig @@ -29,6 +29,7 @@ const page_allocator = std.heap.page_allocator; const parseUnsigned = std.fmt.parseUnsigned; const print = std.debug.print; const std = @import("std"); +const stdout = std.fs.File.stdout; const RegisterEnum = Variables.RegisterEnum; const Variables = @import("Variables.zig"); @@ -52,7 +53,7 @@ const Comparison = struct { } pub fn format(cmp: Comparison, writer: *Writer) Writer.Error!void { - try writer.print("{s}{f}{f}", .{ + try writer.print("{s} {f} {f}", .{ switch (cmp.op) { .lt => "<", .lte => "<=", @@ -68,13 +69,18 @@ const Comparison = struct { }; pub fn main() !void { + var buffer: [80]u8 = undefined; + var writer = stdout().writer(&buffer); var arena = ArenaAllocator.init(page_allocator); defer arena.deinit(); const allocator = arena.allocator(); const args = try argsAlloc(allocator); defer argsFree(allocator, args); if (args.len != 4) { - print("Usage: taosc-synth STACK_SIZE BOTTOM_DIR TOP_DIR", .{}); + try writer.interface.print("Usage: taosc-synth {s} {s} {s}\n", .{ + "STACK_SIZE", "BOTTOM_DIR", "TOP_DIR", + }); + try writer.interface.flush(); exit(1); } const stack_size = try parseUnsigned(usize, args[1], 0); @@ -91,6 +97,7 @@ pub fn main() !void { for (enums.values(CompareOperator)) |op| { const cmp = Comparison{ .lhs = lhs, .op = op, .rhs = rhs }; if (try cmp.check(bot, top)) - print("{f}\n", .{ cmp }); + try writer.interface.print("{f}\n", .{ cmp }); }; + try writer.interface.flush(); } |
