diff options
| author | Arnold Filip <arnold.filip@gmail.com> | 2025-07-21 15:00:15 +0200 |
|---|---|---|
| committer | Arnold Filip <arnold.filip@gmail.com> | 2025-07-21 15:04:57 +0200 |
| commit | 9ae739c4c95aec30e2ac4c49d0dc879ff4b5d169 (patch) | |
| tree | c1376349fa3e568f31096f402ee2f243b1afc814 | |
| parent | 34a7c6c8613fb0ba36b1be1f151c26226e40f332 (diff) | |
Fix zig 0.15.0-dev.1149+4e6a04929 build errors
| -rw-r--r-- | build.zig | 11 | ||||
| -rw-r--r-- | test/tests.zig | 11 |
2 files changed, 12 insertions, 10 deletions
@@ -126,19 +126,18 @@ pub fn build(b: *Build) !void { if (!validate_exercises()) std.process.exit(2); use_color_escapes = false; - if (std.io.getStdErr().supportsAnsiEscapeCodes()) { + if (std.fs.File.stderr().supportsAnsiEscapeCodes()) { use_color_escapes = true; } else if (builtin.os.tag == .windows) { const w32 = struct { - const WINAPI = std.os.windows.WINAPI; const DWORD = std.os.windows.DWORD; const ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004; const STD_ERROR_HANDLE: DWORD = @bitCast(@as(i32, -12)); - extern "kernel32" fn GetStdHandle(id: DWORD) callconv(WINAPI) ?*anyopaque; - extern "kernel32" fn GetConsoleMode(console: ?*anyopaque, out_mode: *DWORD) callconv(WINAPI) u32; - extern "kernel32" fn SetConsoleMode(console: ?*anyopaque, mode: DWORD) callconv(WINAPI) u32; + const GetStdHandle = std.os.windows.kernel32.GetStdHandle; + const GetConsoleMode = std.os.windows.kernel32.GetConsoleMode; + const SetConsoleMode = std.os.windows.kernel32.SetConsoleMode; }; - const handle = w32.GetStdHandle(w32.STD_ERROR_HANDLE); + const handle = w32.GetStdHandle(w32.STD_ERROR_HANDLE).?; var mode: w32.DWORD = 0; if (w32.GetConsoleMode(handle, &mode) != 0) { mode |= w32.ENABLE_VIRTUAL_TERMINAL_PROCESSING; diff --git a/test/tests.zig b/test/tests.zig index 5f64f8e..42c3653 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -161,7 +161,8 @@ const CheckNamedStep = struct { ); defer stderr_file.close(); - const stderr = stderr_file.reader(); + var buffer: [4096]u8 = undefined; + const stderr = stderr_file.reader(&buffer); { // Skip the logo. const nlines = mem.count(u8, root.logo, "\n"); @@ -213,7 +214,8 @@ const CheckStep = struct { ); defer stderr_file.close(); - const stderr = stderr_file.reader(); + var buffer: [4096]u8 = undefined; + const stderr = stderr_file.reader(&buffer); for (exercises) |ex| { if (ex.number() == 1) { // Skip the logo. @@ -298,7 +300,7 @@ fn check( } fn readLine(reader: fs.File.Reader, buf: []u8) !?[]const u8 { - if (try reader.readUntilDelimiterOrEof(buf, '\n')) |line| { + if (try reader.file.deprecatedReader().readUntilDelimiterOrEof(buf, '\n')) |line| { return mem.trimRight(u8, line, " \r\n"); } @@ -405,7 +407,8 @@ fn heal(allocator: Allocator, exercises: []const Exercise, work_path: []const u8 /// difference that returns an error when the temp path cannot be created. pub fn makeTempPath(b: *Build) ![]const u8 { const rand_int = std.crypto.random.int(u64); - const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ Build.hex64(rand_int); + const rand_hex64 = std.fmt.hex(rand_int); + const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ rand_hex64; const path = b.cache_root.join(b.allocator, &.{tmp_dir_sub_path}) catch @panic("OOM"); try b.cache_root.handle.makePath(tmp_dir_sub_path); |
