diff options
author | Karel Zak | 2015-06-05 10:30:52 +0200 |
---|---|---|
committer | Karel Zak | 2015-06-05 10:30:52 +0200 |
commit | 4827093d4b3090389ae0cabb7d8b522cf794ef90 (patch) | |
tree | 19a9ebb15545cfbbe915924afdaec2b3b07fa056 /libsmartcols/src/table_print.c | |
parent | findmnt: add --json (diff) | |
download | kernel-qcow2-util-linux-4827093d4b3090389ae0cabb7d8b522cf794ef90.tar.gz kernel-qcow2-util-linux-4827093d4b3090389ae0cabb7d8b522cf794ef90.tar.xz kernel-qcow2-util-linux-4827093d4b3090389ae0cabb7d8b522cf794ef90.zip |
losetup: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols/src/table_print.c')
-rw-r--r-- | libsmartcols/src/table_print.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libsmartcols/src/table_print.c b/libsmartcols/src/table_print.c index 37d75c962..731879cae 100644 --- a/libsmartcols/src/table_print.c +++ b/libsmartcols/src/table_print.c @@ -539,6 +539,7 @@ static int print_header(struct libscols_table *tb, struct libscols_buffer *buf) if (scols_table_is_noheadings(tb) || scols_table_is_export(tb) || + scols_table_is_json(tb) || list_empty(&tb->tb_lines)) return 0; @@ -942,6 +943,12 @@ int scols_print_table(struct libscols_table *tb) return -EINVAL; DBG(TAB, ul_debugobj(tb, "printing")); + + if (list_empty(&tb->tb_lines)) { + DBG(TAB, ul_debugobj(tb, "ignore -- epmty table")); + return 0; + } + if (!tb->symbols) scols_table_set_symbols(tb, NULL); /* use default */ @@ -964,7 +971,7 @@ int scols_print_table(struct libscols_table *tb) if (!buf) return -ENOMEM; - if (!(scols_table_is_raw(tb) || scols_table_is_export(tb))) { + if (tb->format == SCOLS_FMT_HUMAN) { rc = recount_widths(tb, buf); if (rc != 0) goto done; @@ -972,11 +979,9 @@ int scols_print_table(struct libscols_table *tb) fput_table_open(tb); - if (!scols_table_is_json(tb)) { - rc = print_header(tb, buf); - if (rc) - goto done; - } + rc = print_header(tb, buf); + if (rc) + goto done; if (scols_table_is_tree(tb)) rc = print_tree(tb, buf); |