summaryrefslogtreecommitdiffstats
path: root/libsmartcols
diff options
context:
space:
mode:
authorKarel Zak2017-03-02 16:56:39 +0100
committerKarel Zak2017-03-02 16:56:39 +0100
commitc14224b37463259576cb1344f49719608754e4ec (patch)
treef1d7108ec0feed6d7c07fa9cf8ced3ce97a5fcc5 /libsmartcols
parentsfdisk: note about small partition in man page (diff)
downloadkernel-qcow2-util-linux-c14224b37463259576cb1344f49719608754e4ec.tar.gz
kernel-qcow2-util-linux-c14224b37463259576cb1344f49719608754e4ec.tar.xz
kernel-qcow2-util-linux-c14224b37463259576cb1344f49719608754e4ec.zip
libsmartcols: support columns separators greater than one output cell
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols')
-rw-r--r--libsmartcols/src/table.c1
-rw-r--r--libsmartcols/src/table_print.c9
2 files changed, 6 insertions, 4 deletions
diff --git a/libsmartcols/src/table.c b/libsmartcols/src/table.c
index 68f570d26..4f3b13db4 100644
--- a/libsmartcols/src/table.c
+++ b/libsmartcols/src/table.c
@@ -1102,7 +1102,6 @@ int scols_table_is_tree(const struct libscols_table *tb)
* @sep: separator
*
* Sets the column separator of @tb to @sep.
- * Please note that @sep should always take up a single cell in the output.
*
* Returns: 0, a negative value in case of an error.
*/
diff --git a/libsmartcols/src/table_print.c b/libsmartcols/src/table_print.c
index afcbc1647..1fe700273 100644
--- a/libsmartcols/src/table_print.c
+++ b/libsmartcols/src/table_print.c
@@ -1092,10 +1092,13 @@ static int recount_widths(struct libscols_table *tb, struct libscols_buffer *buf
size_t width = 0, width_min = 0; /* output width */
int trunc_only, rc = 0;
int extremes = 0;
+ size_t colsepsz;
DBG(TAB, ul_debugobj(tb, "recounting widths (termwidth=%zu)", tb->termwidth));
+ colsepsz = mbs_safe_width(colsep(tb));
+
/* set basic columns width
*/
scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
@@ -1110,8 +1113,8 @@ static int recount_widths(struct libscols_table *tb, struct libscols_buffer *buf
is_last = is_last_column(cl);
- width += cl->width + (is_last ? 0 : 1); /* separator for non-last column */
- width_min += cl->width_min + (is_last ? 0 : 1);
+ width += cl->width + (is_last ? 0 : colsepsz); /* separator for non-last column */
+ width_min += cl->width_min + (is_last ? 0 : colsepsz);
extremes += cl->is_extreme;
}
@@ -1291,7 +1294,7 @@ static int recount_widths(struct libscols_table *tb, struct libscols_buffer *buf
width -= r;
} else {
cl->flags |= SCOLS_FL_HIDDEN;
- width -= cl->width + 1; /* +1 means separator between columns */
+ width -= cl->width + colsepsz;
}
}
}