col: backspacing widechars
PATCH 1/1 col: backspacing widechars
From: The Flying Rapist <[email protected]>
Until now, backspace characters have not accounted for characters of widths other than one. This single line amends that.
--- text-utils/col.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
text-utils/col.c +1 -1
@@ -248,7 +248,7 @@ int main(int argc, char **argv)case BS :/* can't go back further */ if (cur_col ==0 )continue ; - --cur_col; + cur_col -= c->c_width;continue ;case CR : cur_col =0 ;
Signature · 1 line
2.11.0
Quoted 1 line · The Flying Rapist
From: The Flying Rapist <[email protected]>
May I remind howto-contribute[1] tells 'using your real name (sorry, no pseudonyms
or anonymous contributions.)' I guess it is Karel's decision whether this contribution
should be resubmitted or do we remove of the pseudonym rule.
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
Quoted 3 lines · Sami Kerola
May I remind howto-contribute[1] tells 'using your real name (sorry, no pseudonyms
or anonymous contributions.)'
I apologize. I missed that part of howto-contribute.txt. Please accept the following.
From: Grady Martin <[email protected]>
Until now, backspace characters have not accounted for characters of widths other than one. This single line amends that.
---text-utils/col.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
text-utils/col.c +1 -1
@@ -248,7 +248,7 @@ int main(int argc, char **argv)case BS :/* can't go back further */ if (cur_col ==0 )continue ; - --cur_col; + cur_col -= c->c_width;continue ;case CR : cur_col =0 ;
--
2.11.0
Karel Zak
maintainerQuoted 8 lines · The Flying Rapist
Quoted 3 lines · Sami Kerola
May I remind howto-contribute[1] tells 'using your real name (sorry, no pseudonyms
or anonymous contributions.)'I apologize. I missed that part of howto-contribute.txt. Please accept the following.
From: Grady Martin <[email protected]>
Thanks.
Quoted 11 lines
Until now, backspace characters have not accounted for characters of widths other than one. This single line amends that.
---text-utils/col.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)text-utils/col.c +0
-0
text-utils/col.c int main(int argc, char **argv) · line 252
Quoted 6 lines
text-utils/col.c +1
-1@@ -248,7 +248,7 @@ int main(int argc, char **argv)case BS :/* can't go back further */ if (cur_col ==0 )continue ; - --cur_col; + cur_col -= c->c_width;continue ;
Where the c->c_width is initialized? It seems 'c' may be uninitialized or points for wrong char. What happen if I press BS more than once? Is 'c' initialized for the right char?
I'm asking because I'm not sure, the code seems strange at the first glance.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 34 lines · Karel Zak
Quoted 8 lines · The Flying Rapist
Quoted 3 lines · Sami Kerola
May I remind howto-contribute[1] tells 'using your real name (sorry, no pseudonyms
or anonymous contributions.)'I apologize. I missed that part of howto-contribute.txt. Please accept the following.
From: Grady Martin <[email protected]>
Thanks.
Quoted 11 lines
Until now, backspace characters have not accounted for characters of widths other than one. This single line amends that.
---text-utils/col.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)text-utils/col.c +0
-0text-utils/col.c int main(int argc, char **argv) · line 252
Quoted 6 lines
text-utils/col.c +1
-1@@ -248,7 +248,7 @@ int main(int argc, char **argv)case BS :/* can't go back further */ if (cur_col ==0 )continue ; - --cur_col; + cur_col -= c->c_width;continue ;Where the
c->c_widthis initialized? It seems 'c' may be uninitialized or points for wrong char. What happen if I press BS more than once? Is 'c' initialized for the right char?
Quoted 2 lines
I'm asking because I'm not sure, the code seems strange at the first glance.
Quite right. The proposed change makes for example
printf " \v\b" | ./col
to crash. How about change below? Updated version survived 1.5 million rounds of afl-fuzz without issues.
p.s. also available from
git://github.com/kerolasa/lelux-utiliteetit.git col
--->8----
From: Grady Martin <[email protected]>
Date: Wed, 4 Jan 2017 22:01:40 +0000
Subject: [PATCH] col: backspacing widechars
Until now, backspace characters have not accounted for characters of widths other than one. This single line amends that.
--- text-utils/col.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
text-utils/col.c +9 -3
@@ -160,7 +160,7 @@ static void __attribute__((__noreturn__)) wrerr(void)int main (int argc,char **argv) { registerwint_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
Signature · 1 line
2.11.0
Quoted 2 lines · Sami Kerola
text-utils/col.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com