lineedit: fix column display for wide and combining chars in TAB completion
function old new delta
unicode_strwidth - 20 +20
read_line_input 4945 4953 +8
unicode_strlen 31 - -31
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/0 up/down: 28/-31) Total: -3 bytes
Signed-off-by: Tomas Heinrich <heinrich.tomas@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 18664b8..8a2ea79 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -992,7 +992,7 @@
/* find the longest file name - use that as the column width */
for (row = 0; row < nrows; row++) {
- l = unicode_strlen(matches[row]);
+ l = unicode_strwidth(matches[row]);
if (column_width < l)
column_width = l;
}
@@ -1012,10 +1012,13 @@
for (nc = 1; nc < ncols && n+nrows < nfiles; n += nrows, nc++) {
printf("%s%-*s", matches[n],
- (int)(column_width - unicode_strlen(matches[n])), ""
+ (int)(column_width - unicode_strwidth(matches[n])), ""
);
}
- puts(matches[n]);
+ if (ENABLE_UNICODE_SUPPORT)
+ puts(printable_string(NULL, matches[n]));
+ else
+ puts(matches[n]);
}
}