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