Re: RES: vt newcons mouse paste issue FIXED

From: Hans Petter Selasky <hps_at_selasky.org>
Date: Wed, 22 Jun 2022 14:01:54 UTC
On 6/22/22 15:36, Ivan Quitschal wrote:
> Hi Hans
> 

Hi Ivan,

I think you should upload the diff at:

https://reviews.freebsd.org/differential/

Make the diff like this:

diff -u -C 999999 sys/dev/vt/vt_buf.c.orig sys/dev/vt/vt_buf.c > a.diff


I see two issues:

1) Pointer arithmetics is not so good!

>                 }
> +               end = buf + i - 1;
> +               while (end > buf && isspace((unsigned char)*end))
> +               {
> +                       *end = '\0';
> +                       end--;
> +               }
> +

I think this would be better and avoid the ">" with pointers!

for (end = buf + i; end-- != buf; ) {
    if (isspace((unsigned char)*end) == false)
	break;
    *end = '\0';
}

Can you explain this:

> -                       buf[i++] = '\r';
> +                       buf[i] = '\r';
>                         buf[i++] = '\n';

'\r' character is now overwritten by '\n' character.

--HPS