zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 94b0d0e80242563f4ad7ad41e3c0f5193a60b70c (tree)
parent 5418efa1e584538dd32589c274498de9ec412162
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Fri,  1 May 2020 15:13:55 -0400

std.progress: handle error from FillConsoleOutputAttribute

I observed this returning an error. Fall back to not doing
terminal stuff if an error occurs here.

See #5244

Diffstat:
Mlib/std/progress.zig | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/std/progress.zig b/lib/std/progress.zig @@ -145,7 +145,7 @@ pub const Progress = struct { if (self.supports_ansi_escape_codes) { end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[{}D", .{self.columns_written}) catch unreachable).len; end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len; - } else if (std.builtin.os.tag == .windows) { + } else if (std.builtin.os.tag == .windows) winapi: { var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined; if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) unreachable; @@ -167,7 +167,11 @@ pub const Progress = struct { fill_chars, cursor_pos, &written, - ) != windows.TRUE) unreachable; + ) != windows.TRUE) { + // Stop trying to write to this file. + self.terminal = null; + break :winapi; + } if (windows.kernel32.FillConsoleOutputCharacterA( file.handle, ' ',