41 lines
1.5 KiB
Diff
41 lines
1.5 KiB
Diff
|
From 02b72c15a53f694f65a377206fba478db91432cd Mon Sep 17 00:00:00 2001
|
||
|
From: Lennart Poettering <lennart@poettering.net>
|
||
|
Date: Tue, 6 Nov 2018 18:37:21 +0100
|
||
|
Subject: [PATCH] format-table: before outputting a color, check if colors are
|
||
|
available
|
||
|
|
||
|
This is in many cases redundant, as a similar check is done by various
|
||
|
callers already, but in other cases (where we read the color from a
|
||
|
static table for example), it's nice to let the color check be done by
|
||
|
the table code itself, and since it doesn't hurt in the other cases just
|
||
|
do it again.
|
||
|
|
||
|
(cherry picked from commit a22318e55492af721879d8692ed039144696bb08)
|
||
|
|
||
|
Related: #1689832
|
||
|
---
|
||
|
src/basic/format-table.c | 6 +++---
|
||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/src/basic/format-table.c b/src/basic/format-table.c
|
||
|
index ac5d66eda2..17be7285cd 100644
|
||
|
--- a/src/basic/format-table.c
|
||
|
+++ b/src/basic/format-table.c
|
||
|
@@ -1255,13 +1255,13 @@ int table_print(Table *t, FILE *f) {
|
||
|
if (j > 0)
|
||
|
fputc(' ', f); /* column separator */
|
||
|
|
||
|
- if (d->color)
|
||
|
+ if (d->color && colors_enabled())
|
||
|
fputs(d->color, f);
|
||
|
|
||
|
fputs(field, f);
|
||
|
|
||
|
- if (d->color)
|
||
|
- fputs(ansi_normal(), f);
|
||
|
+ if (d->color && colors_enabled())
|
||
|
+ fputs(ANSI_NORMAL, f);
|
||
|
}
|
||
|
|
||
|
fputc('\n', f);
|