From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21733 invoked from network); 10 Aug 2006 08:01:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-25) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO,UNPARSEABLE_RELAY autolearn=ham version=3.1.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Aug 2006 08:01:28 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 27741 invoked from network); 10 Aug 2006 08:01:21 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Aug 2006 08:01:21 -0000 Received: (qmail 27430 invoked by alias); 10 Aug 2006 08:01:18 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22595 Received: (qmail 27420 invoked from network); 10 Aug 2006 08:01:17 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 Aug 2006 08:01:17 -0000 Received: (qmail 27501 invoked from network); 10 Aug 2006 08:01:17 -0000 Received: from vms048pub.verizon.net (206.46.252.48) by a.mx.sunsite.dk with SMTP; 10 Aug 2006 08:01:15 -0000 Received: from torch.brasslantern.com ([71.116.95.246]) by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0J3R0084JVLR1X0E@vms048.mailsrvcs.net> for zsh-workers@sunsite.dk; Thu, 10 Aug 2006 03:01:04 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id k7A813jI024017 for ; Thu, 10 Aug 2006 01:01:03 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id k7A812HT024016 for zsh-workers@sunsite.dk; Thu, 10 Aug 2006 01:01:02 -0700 Date: Thu, 10 Aug 2006 01:01:02 -0700 From: Bart Schaefer Subject: Re: PATCH: complist with long display lines In-reply-to: <20060809230445.6eb66ce0.p.w.stephenson@ntlworld.com> To: zsh-workers@sunsite.dk Message-id: <060810010102.ZM24015@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <200608071540.k77FeWcL020899@news01.csr.com> <060807101946.ZM19622@torch.brasslantern.com> <20060809230445.6eb66ce0.p.w.stephenson@ntlworld.com> Comments: In reply to Peter Stephenson "Re: PATCH: complist with long display lines" (Aug 9, 11:04pm) On Aug 9, 11:04pm, Peter Stephenson wrote: } } The main completion code doesn't count an extra line for the screen for } strings that exactly fit the screen width } } The complist code, however, adds 1 to the count of lines (variously held } in ml and mlprinted) if the number of columns just reaches the screen } width. As it only allocates the number of lines that the main } completion code tells it, this causes bad array addressing. Brilliant, Peter. How did you ever track this down? It may be worthwhile (or at least satisfying to paranoid types) to add the following patch, which I've had sitting around uncommitted because it failed to resolve the addressing issues that you seem to finally have identified. This patch prevents the infinite loop alluded to in 21842, by catching cases where an array index starts out negative and decrements from there. It might be unnecessary now, but: Index: Src/Zle/complist.c --- Src/Zle/complist.c 2006-08-10 00:34:13.000000000 -0700 +++ Src/Zle/complist.c.defense 2006-08-10 21:19:26.000000000 -0700 @@ -841,7 +831,7 @@ selectlocalmap(NULL); settyinfo(&shttyinfo); putc('\r', shout); - for (i = columns - 1; i--; ) + for (i = columns - 1; i-- > 0; ) putc(' ', shout); putc('\r', shout); @@ -1162,7 +1148,7 @@ if (mselect >= 0) { int mm = (mcols * ml), i; - for (i = mcols; i--; ) { + for (i = mcols; i-- > 0; ) { DPUTS(mm+i >= mgtabsize, "BUG: invalid position"); mtab[mm + i] = mtmark(NULL); mgtab[mm + i] = mgmark(NULL); @@ -1484,13 +1469,13 @@ int mm = (mcols * ml), i; if (m->flags & CMF_DUMMY) { - for (i = mcols; i--; ) { + for (i = mcols; i-- > 0; ) { DPUTS(mm+i >= mgtabsize, "BUG: invalid position"); mtab[mm + i] = mtmark(mp); mgtab[mm + i] = mgmark(g); } } else { - for (i = mcols; i--; ) { + for (i = mcols; i-- > 0; ) { DPUTS(mm+i >= mgtabsize, "BUG: invalid position"); mtab[mm + i] = mp; mgtab[mm + i] = g; @@ -1545,13 +1523,13 @@ int mm = mcols * ml, i; if (m->flags & CMF_DUMMY) { - for (i = (width ? width : mcols); i--; ) { + for (i = (width ? width : mcols); i-- > 0; ) { DPUTS(mx+mm+i >= mgtabsize, "BUG: invalid position"); mtab[mx + mm + i] = mtmark(mp); mgtab[mx + mm + i] = mgmark(g); } } else { - for (i = (width ? width : mcols); i--; ) { + for (i = (width ? width : mcols); i-- > 0; ) { DPUTS(mx+mm+i >= mgtabsize, "BUG: invalid position"); mtab[mx + mm + i] = mp; mgtab[mx + mm + i] = g; @@ -2184,7 +2142,7 @@ Cmatch **p = mtab; for (y = 0; y < mlines; y++) { - for (x = mcols; x; x--, p++) + for (x = mcols; x > 0; x--, p++) if (*p && !mmarked(*p) && **p && mselect == (**p)->gnum) break; if (x) { @@ -2195,7 +2153,7 @@ int c; while (mlbeg) { - for (q = p, c = columns; c; q++, c--) + for (q = p, c = columns; c > 0; q++, c--) if (*q && !mmarked(*q)) break; if (c) @@ -2228,7 +2180,7 @@ int c; while (mlbeg < mlines) { - for (q = p, c = columns; c; q++, c--) + for (q = p, c = columns; c > 0; q++, c--) if (*q) break; if (c)