* [PATCH] col: backspacing widechars
@ 2016-12-28 9:36 The Flying Rapist
2016-12-28 14:55 ` Sami Kerola
0 siblings, 1 reply; 6+ messages in thread
From: The Flying Rapist @ 2016-12-28 9:36 UTC (permalink / raw)
To: util-linux; +Cc: The Flying Rapist
From: The Flying Rapist <admin@nosuck.org>
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(-)
diff --git a/text-utils/col.c b/text-utils/col.c
index 9b0e23058..c63b46fee 100644
--- a/text-utils/col.c
+++ b/text-utils/col.c
@@ -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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] col: backspacing widechars
2016-12-28 9:36 [PATCH] col: backspacing widechars The Flying Rapist
@ 2016-12-28 14:55 ` Sami Kerola
2016-12-28 20:42 ` The Flying Rapist
0 siblings, 1 reply; 6+ messages in thread
From: Sami Kerola @ 2016-12-28 14:55 UTC (permalink / raw)
To: The Flying Rapist; +Cc: util-linux, The Flying Rapist
On 28 December 2016 at 09:36, The Flying Rapist
<impeccableenglish@gmail.com> wrote:
> From: The Flying Rapist <admin@nosuck.org>
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.
[1] http://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/Documentation/howto-contribute.txt#n71
--
Sami Kerola
http://www.iki.fi/kerolasa/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] col: backspacing widechars
2016-12-28 14:55 ` Sami Kerola
@ 2016-12-28 20:42 ` The Flying Rapist
2017-01-04 11:06 ` Karel Zak
0 siblings, 1 reply; 6+ messages in thread
From: The Flying Rapist @ 2016-12-28 20:42 UTC (permalink / raw)
To: kerolasa; +Cc: util-linux, The Flying Rapist
On 2016年12月28日 14時55分, Sami Kerola wrote:
>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 <admin@nosuck.org>
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(-)
diff --git a/text-utils/col.c b/text-utils/col.c
index 9b0e23058..c63b46fee 100644
--- a/text-utils/col.c
+++ b/text-utils/col.c
@@ -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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] col: backspacing widechars
2016-12-28 20:42 ` The Flying Rapist
@ 2017-01-04 11:06 ` Karel Zak
2017-01-04 22:19 ` Sami Kerola
0 siblings, 1 reply; 6+ messages in thread
From: Karel Zak @ 2017-01-04 11:06 UTC (permalink / raw)
To: The Flying Rapist; +Cc: kerolasa, util-linux, The Flying Rapist
On Wed, Dec 28, 2016 at 03:42:37PM -0500, The Flying Rapist wrote:
> On 2016年12月28日 14時55分, Sami Kerola wrote:
> > 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 <admin@nosuck.org>
Thanks.
>
> 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(-)
>
> diff --git a/text-utils/col.c b/text-utils/col.c
> index 9b0e23058..c63b46fee 100644
> --- a/text-utils/col.c
> +++ b/text-utils/col.c
> @@ -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
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] col: backspacing widechars
2017-01-04 11:06 ` Karel Zak
@ 2017-01-04 22:19 ` Sami Kerola
2017-01-16 11:35 ` Karel Zak
0 siblings, 1 reply; 6+ messages in thread
From: Sami Kerola @ 2017-01-04 22:19 UTC (permalink / raw)
To: Karel Zak; +Cc: The Flying Rapist, kerolasa, util-linux, The Flying Rapist
On Wed, 4 Jan 2017, Karel Zak wrote:
> On Wed, Dec 28, 2016 at 03:42:37PM -0500, The Flying Rapist wrote:
> > On 2016?12?28? 14?55?, Sami Kerola wrote:
> > > 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 <admin@nosuck.org>
>
> Thanks.
>
> >
> > 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(-)
> >
> > diff --git a/text-utils/col.c b/text-utils/col.c
> > index 9b0e23058..c63b46fee 100644
> > --- a/text-utils/col.c
> > +++ b/text-utils/col.c
> > @@ -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.
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 <admin@nosuck.org>
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.
Requsted-by: Grady Martin <admin@nosuck.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
text-utils/col.c | 12 +++++++++---
1 file 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
--
2.11.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] col: backspacing widechars
2017-01-04 22:19 ` Sami Kerola
@ 2017-01-16 11:35 ` Karel Zak
0 siblings, 0 replies; 6+ messages in thread
From: Karel Zak @ 2017-01-16 11:35 UTC (permalink / raw)
To: Sami Kerola; +Cc: The Flying Rapist, kerolasa, util-linux, The Flying Rapist
On Wed, Jan 04, 2017 at 10:19:58PM +0000, Sami Kerola wrote:
> text-utils/col.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-01-16 11:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-28 9:36 [PATCH] col: backspacing widechars The Flying Rapist
2016-12-28 14:55 ` Sami Kerola
2016-12-28 20:42 ` The Flying Rapist
2017-01-04 11:06 ` Karel Zak
2017-01-04 22:19 ` Sami Kerola
2017-01-16 11:35 ` Karel Zak
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.