From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22255 invoked from network); 20 Aug 2006 16:54:51 -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.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO,SUBJ_HAS_UNIQ_ID 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; 20 Aug 2006 16:54:51 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 33361 invoked from network); 20 Aug 2006 16:54:45 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 20 Aug 2006 16:54:45 -0000 Received: (qmail 20098 invoked by alias); 20 Aug 2006 16:54:43 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22638 Received: (qmail 20088 invoked from network); 20 Aug 2006 16:54:42 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 20 Aug 2006 16:54:42 -0000 Received: (qmail 33204 invoked from network); 20 Aug 2006 16:54:42 -0000 Received: from mtaout02-winn.ispmail.ntl.com (81.103.221.48) by a.mx.sunsite.dk with SMTP; 20 Aug 2006 16:54:41 -0000 Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com with ESMTP id <20060820165440.YNCJ27023.mtaout02-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com> for ; Sun, 20 Aug 2006 17:54:40 +0100 Received: from pwslaptop.csr.com ([81.107.41.155]) by aamtaout03-winn.ispmail.ntl.com with SMTP id <20060820165440.MOPA11710.aamtaout03-winn.ispmail.ntl.com@pwslaptop.csr.com> for ; Sun, 20 Aug 2006 17:54:40 +0100 Date: Sun, 20 Aug 2006 17:54:34 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: zstyle is badly broken as of 20060817 Message-Id: <20060820175434.07ec703c.p.w.stephenson@ntlworld.com> In-Reply-To: <060819111155.ZM28512@torch.brasslantern.com> References: <060819111155.ZM28512@torch.brasslantern.com> X-Mailer: Sylpheed version 2.2.6 (GTK+ 2.8.20; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 19 Aug 2006 11:11:55 -0700 Bart Schaefer wrote: > schaefer<532> zstyle ':completion:*' list-prompt '' > schaefer<533> zstyle -L | grep list-prompt > zstyle ':completion:*' list-prompt '' > schaefer<534> zstyle -d ':completion:*' list-prompt > schaefer<535> zstyle | grep list-prompt > list-prompt > schaefer<536> zstyle -L | grep list-prompt > schaefer<537> > > So the list-prompt style is still there even after supposedly being deleted, > but zstyle -L does not list it (and completion behaves as if it is still > set, which is how I even noticed). Your subject line implies this is something new, but it isn't. When the last pattern for a style is deleted the style hangs around, with the effects you see. You'd find it was cosmetic, although confusing and potentially memory hogging, in that there were no contexts given for the style. This fixes it. > schaefer<545> zstyle -s ":completion:${curcontext}:default" list-prompt tmp > schaefer<546> echo $? > 0 I didn't seem to get this effect. It would have to be a different bug, since searching the list of context patterns appears to be correctly terminated even if it's empty. Index: Src/Modules/zutil.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/zutil.c,v retrieving revision 1.18 diff -u -r1.18 zutil.c --- Src/Modules/zutil.c 16 Aug 2006 09:06:40 -0000 1.18 +++ Src/Modules/zutil.c 20 Aug 2006 16:44:11 -0000 @@ -58,9 +58,27 @@ /* Memory stuff. */ +/* + * Free the information for one of the patterns associated with + * a style. + * + * If the style s is passed, prev is the previous pattern in the list, + * found when scanning. We use this to update the list of patterns. + * If this results in their being no remaining patterns, the style + * itself is removed from the list of styles. This isn't optimised, + * since it's not a very frequent operation; we simply scan down the list + * to find the previous entry. + */ static void -freestypat(Stypat p) +freestypat(Stypat p, Style s, Stypat prev) { + if (s) { + if (prev) + prev->next = p->next; + else + s->pats = p->next; + } + zsfree(p->pat); freepatprog(p->prog); if (p->vals) @@ -68,6 +86,20 @@ if (p->eval) freeeprog(p->eval); zfree(p, sizeof(*p)); + + if (s && !s->pats) { + /* No patterns left, free style */ + if (s == zstyles) { + zstyles = s->next; + } else { + Style s2; + for (s2 = zstyles; s2->next != s; s2 = s2->next) + ; + s2->next = s->next; + } + zsfree(s->name); + zfree(s, sizeof(*s)); + } } static void @@ -80,7 +112,7 @@ sn = s->next; for (p = s->pats; p; p = pn) { pn = p->next; - freestypat(p); + freestypat(p, NULL, NULL); } zsfree(s->name); zfree(s, sizeof(*s)); @@ -96,8 +128,9 @@ Style s; for (s = zstyles; s; s = s->next) - if (!strcmp(name, s->name)) + if (!strcmp(name, s->name)) { return s; + } return NULL; } @@ -397,27 +430,22 @@ for (q = NULL, p = s->pats; p; q = p, p = p->next) { if (!strcmp(p->pat, pat)) { - if (q) - q->next = p->next; - else - s->pats = p->next; - freestypat(p); + freestypat(p, s, q); break; } } } } } else { + Style next; Stypat p, q; - for (s = zstyles; s; s = s->next) { + /* careful! style itself may be deleted */ + for (s = zstyles; s; s = next) { + next = s->next; for (q = NULL, p = s->pats; p; q = p, p = p->next) { if (!strcmp(p->pat, args[1])) { - if (q) - q->next = p->next; - else - s->pats = p->next; - freestypat(p); + freestypat(p, s, q); break; } } -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/