summaryrefslogtreecommitdiffstats
path: root/text-utils/col.c
diff options
context:
space:
mode:
authorGrady Martin2017-01-04 23:01:40 +0100
committerSami Kerola2017-01-04 23:01:40 +0100
commit26c91027b2a67c8c3548a8009df157fee9b156ba (patch)
tree4dad93e68037208d0ad06b1f51bf82295a862394 /text-utils/col.c
parentbuild-sys: test_linux_version is Linux only (diff)
downloadkernel-qcow2-util-linux-26c91027b2a67c8c3548a8009df157fee9b156ba.tar.gz
kernel-qcow2-util-linux-26c91027b2a67c8c3548a8009df157fee9b156ba.tar.xz
kernel-qcow2-util-linux-26c91027b2a67c8c3548a8009df157fee9b156ba.zip
col: backspacing widechars
Until now, backspace characters have not accounted for characters of widths other than one. This single line amends that. Requsted-by: Grady Martin <admin@nosuck.org> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'text-utils/col.c')
-rw-r--r--text-utils/col.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/text-utils/col.c b/text-utils/col.c
index 9b0e23058..7bf3708bd 100644
--- a/text-utils/col.c
+++ b/text-utils/col.c
@@ -160,7 +160,7 @@ static void __attribute__((__noreturn__)) wrerr(void)
int main(int argc, char **argv)
{
register wint_t ch;
- CHAR *c;
+ CHAR *c = NULL;
CSET cur_set; /* current character set */
LINE *l; /* current line */
int extra_lines; /* # of lines above first line */
@@ -248,7 +248,10 @@ int main(int argc, char **argv)
case BS: /* can't go back further */
if (cur_col == 0)
continue;
- --cur_col;
+ if (c)
+ cur_col -= c->c_width;
+ else
+ cur_col--;
continue;
case CR:
cur_col = 0;
@@ -369,7 +372,10 @@ int main(int argc, char **argv)
c = &l->l_line[l->l_line_len++];
c->c_char = ch;
c->c_set = cur_set;
- c->c_column = cur_col;
+ if (0 < cur_col)
+ c->c_column = cur_col;
+ else
+ c->c_column = 0;
c->c_width = wcwidth(ch);
/*
* If things are put in out of order, they will need sorting