Date: Thu, 23 Jun 2022 01:48:47 +0900 From: Tomoaki AOKI <junchoon@dec.sakura.ne.jp> To: Ivan Quitschal <tezeka@hotmail.com> Cc: Hans Petter Selasky <hps@selasky.org>, "freebsd-current@freebsd.org" <freebsd-current@freebsd.org>, Kurt Jaeger <pi@freebsd.org> Subject: Re: RES: RES: vt newcons mouse paste issue FIXED Message-ID: <20220623014847.067b18a5ba388639cf6009ce@dec.sakura.ne.jp> In-Reply-To: <CP6P284MB1900DD3D6F41CBAF38CF2CA4CBB29@CP6P284MB1900.BRAP284.PROD.OUTLOOK.COM> References: <CP6P284MB1900CA1ED5B5BADE054ECB34CBB29@CP6P284MB1900.BRAP284.PROD.OUTLOOK.COM> <f6c1ee1c-bdd9-c8d6-1385-145022e6765d@selasky.org> <CP6P284MB1900CC7B7F6343DAB1D1E5BCCBB29@CP6P284MB1900.BRAP284.PROD.OUTLOOK.COM> <41ef5c38-515f-739a-cb47-7cab0e609526@selasky.org> <CP6P284MB1900DD3D6F41CBAF38CF2CA4CBB29@CP6P284MB1900.BRAP284.PROD.OUTLOOK.COM>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi. Not actually tested, but this can cause breakage on non-ascii cases. Maybe also (or instead) iswspace() test would be needed. Possibly additional mbrtowc() in the argument of iswspace(). Please see `man 3 multibyte` and `man 3 iswspace`. (Possibly more to see.) Characters in buf can be multibyte or wide char depending on locale, as vt can show at least UTF-8 characters. Sorry, not looked into enough how UTF-8 characters outside ascii are handled internally on vt. On Wed, 22 Jun 2022 15:01:36 +0000 Ivan Quitschal <tezeka@hotmail.com> wrote: > Hi Hans > > Actually i can , I should've cut off the '\r' 😊 , this is what was causing the term to go bend > > This is the correct diff (option -C 9999 doesn’t worked with -u) > I also included your code for the pts anyway > > > > --- sys/dev/vt/vt_buf.c.orig 2022-06-22 11:48:39.705597000 -0300 > +++ sys/dev/vt/vt_buf.c 2022-06-22 11:51:05.502415000 -0300 > @@ -41,6 +41,7 @@ > #include <sys/malloc.h> > #include <sys/mutex.h> > #include <sys/reboot.h> > +#include <sys/ctype.h> > > #include <dev/vt/vt.h> > > @@ -752,6 +753,7 @@ > { > int i, r, c, cs, ce; > term_pos_t s, e; > + term_char_t *end; > > /* Swap according to window coordinates. */ > if (POS_INDEX(vtbuf_htw(vb, vb->vb_mark_start.tp_row), > @@ -772,10 +774,15 @@ > for (c = cs; c < ce; c++) { > buf[i++] = vb->vb_rows[r][c]; > } > + for (end = buf + i; end-- != buf; ) { > + if (isspace((unsigned char)*end) == false) > + break; > + *end = '\0'; > + } > /* Add new line for all rows, but not for last one. */ > if (r != e.tp_row) { > - buf[i++] = '\r'; > buf[i++] = '\n'; > + buf[i++] = '\0'; > } > } > } > > Works fine here > > Thanks > > --tzk > > -----Mensagem original----- > De: Hans Petter Selasky <hps@selasky.org> > Enviada em: quarta-feira, 22 de junho de 2022 11:02 > Para: Ivan Quitschal <tezeka@hotmail.com>; freebsd-current@freebsd.org > Assunto: Re: RES: vt newcons mouse paste issue FIXED > > On 6/22/22 15:36, Ivan Quitschal wrote: > > Hi Hans > > > > Hi Ivan, > > I think you should upload the diff at: > > https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.freebsd.org%2Fdifferential%2F&data=05%7C01%7C%7C85e3f391dfc941f2852908da5457c75f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637915033252675801%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=4sxXIR9NhIbwD42gIrP4pYcdnUinqae1SNZAjclr2Aw%3D&reserved=0 > > 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 > -- Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20220623014847.067b18a5ba388639cf6009ce>