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