From: Grady Martin Date: Wed, 4 Jan 2017 22:01:40 +0000 (+0000) Subject: col: backspacing widechars X-Git-Tag: v2.30-rc1~298^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26c91027b2a67c8c3548a8009df157fee9b156ba;p=thirdparty%2Futil-linux.git 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 Signed-off-by: Sami Kerola --- diff --git a/text-utils/col.c b/text-utils/col.c index 9b0e230588..7bf3708bd9 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