From 29d18e8ca1c3779af100101d697be22afa572772 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Tue, 20 Dec 2022 07:16:55 +0100 Subject: [PATCH] Update to Zig v0.11-ish. --- zig-impl/src/main.zig | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/zig-impl/src/main.zig b/zig-impl/src/main.zig index cc87afe..1d2fe23 100644 --- a/zig-impl/src/main.zig +++ b/zig-impl/src/main.zig @@ -160,7 +160,7 @@ pub const Event = struct { pub fn format(self: Self, comptime _: []const u8, _: fmt.FormatOptions, out_stream: anytype) !void { try fmt.format(out_stream - , "{}, origin: {}, index {}, message: [{}]" + , "{}, origin: {}, index {}, message: [{?}]" , .{ self.@"type", self.origin, self.index, self.m} ); } @@ -251,7 +251,7 @@ pub const Connection = struct { } pub fn format(self: Self, comptime _: []const u8, _: fmt.FormatOptions, out_stream: anytype) !void { - try fmt.format(out_stream, "{}, path {s}", .{ self.@"type", self.path}); + try fmt.format(out_stream, "{}, path {?s}", .{ self.@"type", self.path}); if (self.server) |s| { try fmt.format(out_stream, "{}" , .{s}); @@ -337,7 +337,15 @@ pub const Context = struct { pub fn init(allocator: std.mem.Allocator) !Self { print("Context init\n", .{}); - var rundir = try std.process.getEnvVarOwned(allocator, "RUNDIR"); + var rundir = std.process.getEnvVarOwned(allocator, "RUNDIR") catch |err| switch(err) { + error.EnvironmentVariableNotFound => blk: { + print("RUNTIME variable not set, using default /tmp/runtime\n", .{}); + break :blk try allocator.dupeZ(u8, "/tmp/runtime"); + }, + else => { + return err; + }, + }; defer allocator.free(rundir); print("rundir: {s}\n", .{rundir});