authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-09 10:34:10-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-09 10:34:10-07:00
log7c4c5495bebcb9cbd581b8198d51d13d8b7d7a8d
treeed1598e262b73683e62413480dc6d80fc95ee69e
parentf75cdd1acd0929792c33766bd1d093d897c65113

stage2: fix stderr deadlock and slightly wrong tty coloring


1 files changed, 4 insertions(+), 3 deletions(-)

src/Compilation.zig+4-3
...@@ -285,7 +285,7 @@ pub const AllErrors = struct {...@@ -285,7 +285,7 @@ pub const AllErrors = struct {
285 const held = std.debug.getStderrMutex().acquire();285 const held = std.debug.getStderrMutex().acquire();
286 defer held.release();286 defer held.release();
287 const stderr = std.io.getStdErr();287 const stderr = std.io.getStdErr();
288 return msg.renderToStdErrInner(ttyconf, stderr, "error", .Red) catch return;288 return msg.renderToStdErrInner(ttyconf, stderr, "error:", .Red) catch return;
289 }289 }
290290
291 fn renderToStdErrInner(291 fn renderToStdErrInner(
...@@ -298,6 +298,7 @@ pub const AllErrors = struct {...@@ -298,6 +298,7 @@ pub const AllErrors = struct {
298 const stderr = stderr_file.writer();298 const stderr = stderr_file.writer();
299 switch (msg) {299 switch (msg) {
300 .src => |src| {300 .src => |src| {
301 ttyconf.setColor(stderr, .Bold);
301 try stderr.print("{s}:{d}:{d}: ", .{302 try stderr.print("{s}:{d}:{d}: ", .{
302 src.src_path,303 src.src_path,
303 src.line + 1,304 src.line + 1,
...@@ -317,11 +318,11 @@ pub const AllErrors = struct {...@@ -317,11 +318,11 @@ pub const AllErrors = struct {
317 ttyconf.setColor(stderr, .Reset);318 ttyconf.setColor(stderr, .Reset);
318 }319 }
319 for (src.notes) |note| {320 for (src.notes) |note| {
320 try note.renderToStdErrInner(ttyconf, stderr_file, "note", .Cyan);321 try note.renderToStdErrInner(ttyconf, stderr_file, "note:", .Cyan);
321 }322 }
322 },323 },
323 .plain => |plain| {324 .plain => |plain| {
324 std.debug.print("{s}: {s}\n", .{ kind, plain.msg });325 stderr.print("{s}: {s}\n", .{ kind, plain.msg });
325 },326 },
326 }327 }
327 }328 }