| ... | ... | @@ -50,14 +50,10 @@ pub const LineInfo = struct { |
| 50 | 50 | } |
| 51 | 51 | }; |
| 52 | 52 | |
| 53 | | /// Tries to write to stderr, unbuffered, and ignores any error returned. |
| 54 | | /// Does not append a newline. |
| 55 | | var stderr_file: File = undefined; |
| 56 | | var stderr_file_writer: File.Writer = undefined; |
| 57 | | |
| 58 | | var stderr_stream: ?*File.OutStream = null; |
| 59 | 53 | var stderr_mutex = std.Mutex.init(); |
| 60 | 54 | |
| 55 | /// Tries to write to stderr, unbuffered, and ignores any error returned. |
| 56 | /// Does not append a newline. |
| 61 | 57 | pub fn warn(comptime fmt: []const u8, args: var) void { |
| 62 | 58 | const held = stderr_mutex.acquire(); |
| 63 | 59 | defer held.release(); |
| ... | ... | @@ -65,16 +61,8 @@ pub fn warn(comptime fmt: []const u8, args: var) void { |
| 65 | 61 | nosuspend stderr.print(fmt, args) catch return; |
| 66 | 62 | } |
| 67 | 63 | |
| 68 | | pub fn getStderrStream() *File.OutStream { |
| 69 | | if (stderr_stream) |st| { |
| 70 | | return st; |
| 71 | | } else { |
| 72 | | stderr_file = io.getStdErr(); |
| 73 | | stderr_file_writer = stderr_file.outStream(); |
| 74 | | const st = &stderr_file_writer; |
| 75 | | stderr_stream = st; |
| 76 | | return st; |
| 77 | | } |
| 64 | pub fn getStderrStream() File.OutStream { |
| 65 | return io.getStdErr().outStream(); |
| 78 | 66 | } |
| 79 | 67 | |
| 80 | 68 | pub fn getStderrMutex() *std.Mutex { |
| ... | ... | @@ -99,6 +87,7 @@ pub fn detectTTYConfig() TTY.Config { |
| 99 | 87 | if (process.getEnvVarOwned(allocator, "ZIG_DEBUG_COLOR")) |_| { |
| 100 | 88 | return .escape_codes; |
| 101 | 89 | } else |_| { |
| 90 | const stderr_file = io.getStdErr(); |
| 102 | 91 | if (stderr_file.supportsAnsiEscapeCodes()) { |
| 103 | 92 | return .escape_codes; |
| 104 | 93 | } else if (builtin.os.tag == .windows and stderr_file.isTty()) { |
| ... | ... | @@ -458,6 +447,7 @@ pub const TTY = struct { |
| 458 | 447 | .Reset => out_stream.writeAll(RESET) catch return, |
| 459 | 448 | }, |
| 460 | 449 | .windows_api => if (builtin.os.tag == .windows) { |
| 450 | const stderr_file = io.getStdErr(); |
| 461 | 451 | const S = struct { |
| 462 | 452 | var attrs: windows.WORD = undefined; |
| 463 | 453 | var init_attrs = false; |