Skip to content

Commit 8055d47

Browse files
committed
support both zig 0.15 and 0.16.0-dev
1 parent beec316 commit 8055d47

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

src/cli.zig

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ pub fn panic(
4242
w.print("Unable to dump stack trace: debug info stripped\n", .{}) catch {};
4343
break :blk;
4444
}
45-
std.debug.writeCurrentStackTrace(.{ .first_address = ret_addr }, w, .no_color) catch |err| {
46-
w.print("Unable to dump stack trace: {t}\n", .{err}) catch {};
47-
break :blk;
48-
};
45+
46+
if (builtin.zig_version.minor != 15) {
47+
std.debug.writeCurrentStackTrace(.{ .first_address = ret_addr }, w, .no_color) catch |err| {
48+
w.print("Unable to dump stack trace: {t}\n", .{err}) catch {};
49+
break :blk;
50+
};
51+
}
4952
}
5053

5154
if (builtin.mode == .Debug) @breakpoint();

src/cli/check.zig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const builtin = @import("builtin");
12
const std = @import("std");
23
const super = @import("superhtml");
34

@@ -107,7 +108,14 @@ fn checkFile(
107108
defer _ = arena_impl.reset(.retain_capacity);
108109
const arena = arena_impl.allocator();
109110

110-
const in_bytes = try base_dir.readFileAllocOptions(
111+
const in_bytes = if (builtin.zig_version.minor == 15) try base_dir.readFileAllocOptions(
112+
arena,
113+
sub_path,
114+
super.max_size,
115+
null,
116+
.of(u8),
117+
0,
118+
) else try base_dir.readFileAllocOptions(
111119
sub_path,
112120
arena,
113121
.limited(super.max_size),

src/cli/fmt.zig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const builtin = @import("builtin");
12
const std = @import("std");
23
const Allocator = std.mem.Allocator;
34
const Writer = std.Io.Writer;
@@ -118,7 +119,14 @@ fn formatFile(
118119
defer _ = arena_impl.reset(.retain_capacity);
119120
const arena = arena_impl.allocator();
120121

121-
const in_bytes = try base_dir.readFileAllocOptions(
122+
const in_bytes = if (builtin.zig_version.minor == 15) try base_dir.readFileAllocOptions(
123+
arena,
124+
sub_path,
125+
super.max_size,
126+
null,
127+
.of(u8),
128+
0,
129+
) else try base_dir.readFileAllocOptions(
122130
sub_path,
123131
arena,
124132
.limited(super.max_size),

src/cli/interface.zig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const builtin = @import("builtin");
12
const std = @import("std");
23
const super = @import("superhtml");
34

@@ -55,7 +56,14 @@ fn printInterfaceFromFile(
5556
defer _ = arena_impl.reset(.retain_capacity);
5657
const arena = arena_impl.allocator();
5758

58-
const in_bytes = try base_dir.readFileAllocOptions(
59+
const in_bytes = if (builtin.zig_version.minor == 15) try base_dir.readFileAllocOptions(
60+
arena,
61+
sub_path,
62+
super.max_size,
63+
null,
64+
.of(u8),
65+
0,
66+
) else try base_dir.readFileAllocOptions(
5967
sub_path,
6068
arena,
6169
.limited(super.max_size),

0 commit comments

Comments
 (0)