summaryrefslogtreecommitdiffstats
path: root/libsmartcols
diff options
context:
space:
mode:
authorKarel Zak2018-04-05 12:12:25 +0200
committerKarel Zak2018-04-05 12:12:25 +0200
commitde306264958bac8c9ec908172636ca62bc893861 (patch)
tree1ddf615047ccc766e8ee9fd3a53bfdbccceae53e /libsmartcols
parentlsmem: make output more compatible with another utils (diff)
downloadkernel-qcow2-util-linux-de306264958bac8c9ec908172636ca62bc893861.tar.gz
kernel-qcow2-util-linux-de306264958bac8c9ec908172636ca62bc893861.tar.xz
kernel-qcow2-util-linux-de306264958bac8c9ec908172636ca62bc893861.zip
libsmartcols: make sure boolean is true/false only
.. and never "null". Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols')
-rw-r--r--libsmartcols/src/table_print.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libsmartcols/src/table_print.c b/libsmartcols/src/table_print.c
index 26b138291..10126fd79 100644
--- a/libsmartcols/src/table_print.c
+++ b/libsmartcols/src/table_print.c
@@ -467,14 +467,18 @@ static int print_data(struct libscols_table *tb,
case SCOLS_FMT_JSON:
fputs_quoted_json_lower(scols_cell_get_data(&cl->header), tb->out);
fputs(":", tb->out);
- if (!*data)
- fputs("null", tb->out);
- else switch (cl->json_type) {
+ switch (cl->json_type) {
case SCOLS_JSON_STRING:
- fputs_quoted_json(data, tb->out);
+ if (!*data)
+ fputs("null", tb->out);
+ else
+ fputs_quoted_json(data, tb->out);
break;
case SCOLS_JSON_NUMBER:
- fputs(data, tb->out);
+ if (!*data)
+ fputs("null", tb->out);
+ else
+ fputs(data, tb->out);
break;
case SCOLS_JSON_BOOLEAN:
fputs(!*data ? "false" :