From a60fadd248af4ab49ef603b8185bf148c72841dd Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Fri, 20 Sep 2024 15:20:39 +0200 Subject: [PATCH] make compilable on windows --- src/main.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.zig b/src/main.zig index 29691e6..5ac136e 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,7 +1,7 @@ const std = @import("std"); const info = std.log.info; const debug = std.log.debug; -const stderr = std.io.getStdErr().writer(); +//const stderr = std.io.getStdErr().writer(); const print = std.debug.print; const eql = std.mem.eql; const Allocator = std.mem.Allocator; @@ -297,9 +297,9 @@ fn read_config(allocator: Allocator, config_location: []const u8) !ArrayList(Otp number_of_errors += 1; switch (err) { error.UnexpectedCharacter, error.InvalidFormat => { - try stderr.print("Unexpected character in line {d} in file {s}. Line will be ignored.\n", .{ line_no, config_location }); + try std.io.getStdErr().writer().print("Unexpected character in line {d} in file {s}. Line will be ignored.\n", .{ line_no, config_location }); if (number_of_errors >= 10) { - try stderr.print("too many parsing errors\n", .{}); + try std.io.getStdErr().writer().print("too many parsing errors\n", .{}); return ArgumentError.TooManyParsinErrors; } }, @@ -322,13 +322,13 @@ fn read_config(allocator: Allocator, config_location: []const u8) !ArrayList(Otp error.BadPathName, error.InvalidWtf8, => { - try stderr.print("cannot open config file: {}\n", .{err}); + try std.io.getStdErr().writer().print("cannot open config file: {}\n", .{err}); }, error.FileNotFound => { - try stderr.print("config file not found. Create a new config file in $HOME/.zig-totp or $XDG_CONFIG_HOME/zig-totp.\n", .{}); + try std.io.getStdErr().writer().print("config file not found. Create a new config file in $HOME/.zig-totp or $XDG_CONFIG_HOME/zig-totp.\n", .{}); }, error.IsDir => { - try stderr.print("the configuration location must be a file, but is a directory.\n", .{}); + try std.io.getStdErr().writer().print("the configuration location must be a file, but is a directory.\n", .{}); }, else => { return err;