aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-05-22 17:17:32 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-05-22 17:17:32 -0700
commit51701fb2da3562363d2c4966c5bf5d1b0ccad1a6 (patch)
treef0dd3317e58873dc459d9a7a85e8646459055123 /src/Compilation.zig
parent63aabbbba7872eb5178c32235bba260a13d6869a (diff)
downloadzig-51701fb2da3562363d2c4966c5bf5d1b0ccad1a6.tar.gz
zig-51701fb2da3562363d2c4966c5bf5d1b0ccad1a6.zip
stage2: omit printing source lines in compile errors
when configured to not use tty awareness
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index c11a273a4d..50dc97a929 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -357,16 +357,18 @@ pub const AllErrors = struct {
ttyconf.setColor(stderr, .Bold);
try stderr.print(" {s}\n", .{src.msg});
ttyconf.setColor(stderr, .Reset);
- if (src.source_line) |line| {
- for (line) |b| switch (b) {
- '\t' => try stderr.writeByte(' '),
- else => try stderr.writeByte(b),
- };
- try stderr.writeByte('\n');
- try stderr.writeByteNTimes(' ', src.column);
- ttyconf.setColor(stderr, .Green);
- try stderr.writeAll("^\n");
- ttyconf.setColor(stderr, .Reset);
+ if (ttyconf != .no_color) {
+ if (src.source_line) |line| {
+ for (line) |b| switch (b) {
+ '\t' => try stderr.writeByte(' '),
+ else => try stderr.writeByte(b),
+ };
+ try stderr.writeByte('\n');
+ try stderr.writeByteNTimes(' ', src.column);
+ ttyconf.setColor(stderr, .Green);
+ try stderr.writeAll("^\n");
+ ttyconf.setColor(stderr, .Reset);
+ }
}
for (src.notes) |note| {
try note.renderToStdErrInner(ttyconf, stderr_file, "note:", .Cyan, indent);