From nobody Wed Jun 22 16:48:47 2022 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 90D5F85FD36 for ; Wed, 22 Jun 2022 16:48:53 +0000 (UTC) (envelope-from junchoon@dec.sakura.ne.jp) Received: from www121.sakura.ne.jp (www121.sakura.ne.jp [153.125.133.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4LSq8g64RMz4nqw; Wed, 22 Jun 2022 16:48:51 +0000 (UTC) (envelope-from junchoon@dec.sakura.ne.jp) Received: from kalamity.joker.local (123-1-85-147.area1b.commufa.jp [123.1.85.147]) (authenticated bits=0) by www121.sakura.ne.jp (8.16.1/8.16.1/[SAKURA-WEB]/20201212) with ESMTPA id 25MGmlOu095719; Thu, 23 Jun 2022 01:48:47 +0900 (JST) (envelope-from junchoon@dec.sakura.ne.jp) Date: Thu, 23 Jun 2022 01:48:47 +0900 From: Tomoaki AOKI To: Ivan Quitschal Cc: Hans Petter Selasky , "freebsd-current@freebsd.org" , Kurt Jaeger Subject: Re: RES: RES: vt newcons mouse paste issue FIXED Message-Id: <20220623014847.067b18a5ba388639cf6009ce@dec.sakura.ne.jp> In-Reply-To: References: <41ef5c38-515f-739a-cb47-7cab0e609526@selasky.org> Organization: Junchoon corps X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; amd64-portbld-freebsd13.0) List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4LSq8g64RMz4nqw X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of junchoon@dec.sakura.ne.jp has no SPF policy when checking 153.125.133.21) smtp.mailfrom=junchoon@dec.sakura.ne.jp X-Spamd-Result: default: False [-1.57 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; HAS_ORG_HEADER(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-0.999]; FREEMAIL_TO(0.00)[hotmail.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:7684, ipnet:153.125.128.0/18, country:JP]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[123.1.85.147:received]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.98)[-0.976]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_LONG(-1.00)[-0.999]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[sakura.ne.jp]; AUTH_NA(1.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; R_SPF_NA(0.00)[no SPF record]; MLMMJ_DEST(0.00)[freebsd-current]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N 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 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 > #include > #include > +#include > > #include > > @@ -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 > Enviada em: quarta-feira, 22 de junho de 2022 11:02 > Para: Ivan Quitschal ; 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