From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29823 invoked from network); 30 Oct 2008 22:01:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 30 Oct 2008 22:01:21 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 30413 invoked from network); 30 Oct 2008 22:01:14 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 Oct 2008 22:01:14 -0000 Received: (qmail 9514 invoked by alias); 30 Oct 2008 22:01:08 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25975 Received: (qmail 9494 invoked from network); 30 Oct 2008 22:01:06 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 30 Oct 2008 22:01:06 -0000 Received: from mtaout03-winn.ispmail.ntl.com (mtaout03-winn.ispmail.ntl.com [81.103.221.49]) by bifrost.dotsrc.org (Postfix) with ESMTP id E1B8880524C0 for ; Thu, 30 Oct 2008 23:01:02 +0100 (CET) Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20081030220058.UKGV14139.mtaout03-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Thu, 30 Oct 2008 22:00:58 +0000 Received: from pws-pc ([81.107.43.40]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20081030220057.EZBZ21638.aamtaout02-winn.ispmail.ntl.com@pws-pc> for ; Thu, 30 Oct 2008 22:00:57 +0000 Date: Thu, 30 Oct 2008 22:00:46 +0000 From: Peter Stephenson To: Zsh workers Subject: Re: completion matching problem with 4.3.8 Message-ID: <20081030220046.2e94bcfc@pws-pc> In-Reply-To: <24068.1225366130@thecus> References: <24068.1225366130@thecus> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.12; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.0 c=1 a=vpNQ4glSNfQA:10 a=2HVltibiJvcA:10 a=NLZqzBF-AAAA:8 a=Pszqn0GcipekhXhB99AA:9 a=iDf_suF-TJw1DY1JFKwA:7 a=Rdv23iqFekQc0Vv-sqA4gOlDKWEA:4 a=VkNj9pNNdSIA:10 a=-hJg1tCh9CgA:10 a=_dQi-Dcv4p4A:10 a=LY0hPdMaydYA:10 X-Virus-Scanned: ClamAV 0.92.1/8544/Thu Oct 30 19:59:19 2008 on bifrost X-Virus-Status: Clean On Thu, 30 Oct 2008 12:28:50 +0100 Oliver Kiddle wrote: > There seems to be a problem with matching control. > > touch PacketDefinitionSAXHandler.h PacketListBox.cpp PacketListBox.h PacketsDialog.h > zsh -f > autoload -U compinit; compinit > zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' > : P > --> Completes to 'Packets' instead of just 'Packet' (Well, took an hour and three quarter or so.) This *might* be the fix to the original bug. The valgrind error in pattern_match_restrict() about uninitialised memory was because at that point the memory is deliberately uninitialised---we're building up the matched line. We should therefore be testing for the case where we're doing that (prestrict != NULL). If we get to the end and prestrict is not NULL, we haven't succeeded in building the line because we haven't fulfilled all the restrictions, so we should return 0, which is the fix for the bug above, perhaps. I deliberately left in some debug tests that I added while tracking this down. You get file and line number; anything else is superflous here. Someone should try some hairy matching just to make sure. Index: Src/Zle/compmatch.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/compmatch.c,v retrieving revision 1.60 diff -u -r1.60 compmatch.c --- Src/Zle/compmatch.c 30 Oct 2008 20:29:56 -0000 1.60 +++ Src/Zle/compmatch.c 30 Oct 2008 21:54:59 -0000 @@ -156,6 +156,7 @@ r->next = NULL; r->line = l; r->llen = ll; r->word = w; r->wlen = wl; + DPUTS(wl > 0 && !*w, "Bad word"); r->orig = o; r->olen = ol; r->slen = 0; r->flags = fl; @@ -416,6 +417,7 @@ } else { lp->line = l; lp->llen = wl; lp->word = w; lp->wlen = wl; + DPUTS(wl > 0 && !*w, "Bad word"); lp->orig = o; lp->olen = ol; } if (o || ol) @@ -1242,7 +1244,7 @@ /* * Check if the given pattern matches the given string. - * p and s are either anchor or line pattern and string; + * p and s are either anchor or line pattern and string; * wp and ws are word (candidate) pattern and string * * If only one pattern is given, we just check if characters match. @@ -1273,7 +1275,7 @@ int wc, wind; int len = 0, wlen, mt, wmt; - while (p && wp && *s && *ws) { + while (p && wp && (prestrict || *s) && *ws) { /* First test the word character */ if (*ws == Meta) { wc = STOUC(ws[1]) ^ 32; @@ -1387,7 +1389,7 @@ wp = wp->next; } - while (p && *s) { + while (p && (prestrict || *s)) { if (prestrict) { /* * As above, but with even less info to go on. @@ -1438,6 +1440,11 @@ s += len; } + if (prestrict) { + /* Restriction with nothing to match */ + return 0; + } + while (wp && *ws) { /* No funny business when we only have the word pattern. */ if (*ws == Meta) { @@ -2057,6 +2064,7 @@ } else if (md->len != md->olen) { r->wlen = md->len; r->word = md->str - (sfx ? md->len : 0); + DPUTS(r->wlen > 0 && !*r->word, "Bad word"); } return r; } -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/