From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 10423 invoked from network); 18 Jun 2020 11:17:20 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 18 Jun 2020 11:17:20 -0000 Received: (qmail 8282 invoked by alias); 18 Jun 2020 11:17:13 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 46070 Received: (qmail 18105 invoked by uid 1010); 18 Jun 2020 11:17:13 -0000 X-Qmail-Scanner-Diagnostics: from out4-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25842. spamassassin: 3.4.4. Clear:RC:0(66.111.4.28):SA:0(-2.6/5.0):. Processed in 3.003333 secs); 18 Jun 2020 11:17:13 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudejgedgfeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkjghfofggtgfgsehtqh dttdertdejnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggrnhhi vghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpefhtdetfeehveeutd ehuddtieefgeettedtjedtffehudeiieejleetteekudetheenucfkphepjeelrddujeei rdefledrieelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Date: Thu, 18 Jun 2020 11:16:26 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: [PATCH] Re: RFC: region_highlight inter-plugin interoperability: echo service? Message-ID: <20200618111626.45cd40a3@tarpaulin.shahaf.local2> In-Reply-To: <20200618103311.62307eb5@tarpaulin.shahaf.local2> References: <20200606072018.GA14049@tarpaulin.shahaf.local2> <20200618103311.62307eb5@tarpaulin.shahaf.local2> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Daniel Shahaf wrote on Thu, 18 Jun 2020 10:33 +0000: > +++ b/Src/Zle/zle_refresh.c > @@ -414,16 +414,19 @@ get_region_highlight(UNUSED(Param pm)) > arrsize--; > rhp++, arrp++) { > char digbuf1[DIGBUFSIZE], digbuf2[DIGBUFSIZE]; > - int atrlen =3D 0, alloclen; > + int atrlen, alloclen; > + const char memo_equals[] =3D "memo=3D"; > =20 > sprintf(digbuf1, "%d", rhp->start); > sprintf(digbuf2, "%d", rhp->end); > =20 > atrlen =3D output_highlight(rhp->atr, NULL); > alloclen =3D atrlen + strlen(digbuf1) + strlen(digbuf2) + > - 3; /* 2 spaces, 1 0 */ > + 3; /* 2 spaces, 1 terminating NUL */ > if (rhp->flags & ZRH_PREDISPLAY) > alloclen +=3D 2; /* "P " */ > + if (rhp->memo) > + alloclen +=3D 1 /* space */ + strlen(memo_equals) + strlen(rhp->mem= o); > *arrp =3D (char *)zhalloc(alloclen * sizeof(char)); > /* > * On input we allow a space after the flags. > @@ -436,6 +439,12 @@ get_region_highlight(UNUSED(Param pm)) > (rhp->flags & ZRH_PREDISPLAY) ? "P" : "", > digbuf1, digbuf2); > (void)output_highlight(rhp->atr, *arrp + strlen(*arrp)); > + > + if (rhp->memo) { > + strcat(*arrp, " "); > + strcat(*arrp, memo_equals); > + strcat(*arrp, rhp->memo); > + } > } =20 > *arrp =3D NULL; > return retarr; > +++ b/Src/Zle/zle_utils.c > @@ -557,6 +557,22 @@ zlegetline(int *ll, int *cs) > +/* > + * free() the 'memo' elements of region_highlights. > + */ > + > +/**/ > +void > +free_region_highlights_memos(void) > +{ > + struct region_highlight *rhp; > + for (rhp =3D region_highlights; > + rhp < region_highlights + n_region_highlights; > + rhp++) { > + zsfree(rhp->memo); s/zsfree/zfree/ since the calculation of alloclen in get_region_highlight() can result in an alloclen that's different to strlen(rhp->memo)+1=C2=A0=E2=80=94 at le= ast when the ZRH_PREDISPLAY bit is set. (This only matters for --enable-zsh-mem builds, and even then only if alloclen happens to be exactly the one value that will cause zfree()'s fr_rec condition's truth value to flip, but still.) Cheers, Daniel > + } > +} =20