diff options
author | Karel Zak | 2016-02-10 15:25:38 +0100 |
---|---|---|
committer | Karel Zak | 2016-02-10 15:34:21 +0100 |
commit | d94c519877278124691be5ea3c8dbc729c1962e5 (patch) | |
tree | 3f9e598d652051a2f9bc29d3eb49e1deb096f87f /lib/mbsalign.c | |
parent | libsmartcols: use libscols_cell for title (diff) | |
download | kernel-qcow2-util-linux-d94c519877278124691be5ea3c8dbc729c1962e5.tar.gz kernel-qcow2-util-linux-d94c519877278124691be5ea3c8dbc729c1962e5.tar.xz kernel-qcow2-util-linux-d94c519877278124691be5ea3c8dbc729c1962e5.zip |
libsmartcols: support multi-line cells
The initial implementation has been introduced by SCOLS_FL_WRAP columns,
but this patch clean ups all and makes things more elegant.
Note that use SCOLS_FL_TREE | SCOLS_FL_WRAP for a column is bad idea
and I don't think we need to fix it.
References: https://github.com/karelzak/util-linux/issues/269
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/mbsalign.c')
-rw-r--r-- | lib/mbsalign.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/mbsalign.c b/lib/mbsalign.c index a9cf84521..2a8de2f59 100644 --- a/lib/mbsalign.c +++ b/lib/mbsalign.c @@ -246,6 +246,7 @@ wc_truncate (wchar_t *wc, size_t width) } if (cells + next_cells > width) break; + cells += next_cells; wc++; } @@ -290,7 +291,7 @@ mbs_truncate(char *str, size_t *width) if (sz == (ssize_t) -1) goto done; - wcs = malloc((sz + 1) * sizeof(wchar_t)); + wcs = calloc(1, (sz + 1) * sizeof(wchar_t)); if (!wcs) goto done; |