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