summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/table_print.c
diff options
context:
space:
mode:
authorKarel Zak2016-08-31 12:05:21 +0200
committerKarel Zak2016-08-31 12:05:21 +0200
commitd7cda881d57867d46c6c53d1a9a725d0ed1343a1 (patch)
treece778ed38049c4750adc295db19972e225220f90 /libsmartcols/src/table_print.c
parentlib/loopdev: Set errno in is_loopdev on error (diff)
downloadkernel-qcow2-util-linux-d7cda881d57867d46c6c53d1a9a725d0ed1343a1.tar.gz
kernel-qcow2-util-linux-d7cda881d57867d46c6c53d1a9a725d0ed1343a1.tar.xz
kernel-qcow2-util-linux-d7cda881d57867d46c6c53d1a9a725d0ed1343a1.zip
libsmartcols: don't print title color is colors disabled
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols/src/table_print.c')
-rw-r--r--libsmartcols/src/table_print.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libsmartcols/src/table_print.c b/libsmartcols/src/table_print.c
index 4b250eb0f..d51089b99 100644
--- a/libsmartcols/src/table_print.c
+++ b/libsmartcols/src/table_print.c
@@ -700,7 +700,7 @@ static int print_line(struct libscols_table *tb,
static int print_title(struct libscols_table *tb)
{
- int rc;
+ int rc, color = 0;
mbs_align_t align;
size_t len = 0, width;
char *title = NULL, *buf = NULL;
@@ -754,13 +754,16 @@ static int print_title(struct libscols_table *tb)
goto done;
}
- if (tb->title.color)
+ if (tb->colors_wanted && tb->title.color)
+ color = 1;
+ if (color)
fputs(tb->title.color, tb->out);
fputs(title, tb->out);
- if (tb->title.color)
+ if (color)
fputs(UL_COLOR_RESET, tb->out);
+
fputc('\n', tb->out);
rc = 0;
done: