From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20988 invoked from network); 30 Mar 2008 22:11:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 30 Mar 2008 22:11:10 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 84059 invoked from network); 30 Mar 2008 22:11:00 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 Mar 2008 22:11:00 -0000 Received: (qmail 15274 invoked by alias); 30 Mar 2008 22:10:56 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24780 Received: (qmail 15249 invoked from network); 30 Mar 2008 22:10:55 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 30 Mar 2008 22:10:55 -0000 Received: from mtaout02-winn.ispmail.ntl.com (mtaout02-winn.ispmail.ntl.com [81.103.221.48]) by bifrost.dotsrc.org (Postfix) with ESMTP id 019278059062 for ; Mon, 31 Mar 2008 00:10:50 +0200 (CEST) Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com with ESMTP id <20080330221342.KOVD27871.mtaout02-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com> for ; Sun, 30 Mar 2008 23:13:42 +0100 Received: from pws-pc ([81.107.40.67]) by aamtaout01-winn.ispmail.ntl.com with ESMTP id <20080330221429.JUFZ219.aamtaout01-winn.ispmail.ntl.com@pws-pc> for ; Sun, 30 Mar 2008 23:14:29 +0100 Date: Sun, 30 Mar 2008 22:10:05 +0100 From: Peter Stephenson To: zsh-workers Subject: Re: #c flag wrong behaviour Message-ID: <20080330221005.6d5551b3@pws-pc> In-Reply-To: <20080329161300.GA19193@okita> References: <20080329161300.GA19193@okita> X-Mailer: Claws Mail 3.3.1 (GTK+ 2.12.5; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.91.2/6483/Sun Mar 30 22:51:12 2008 on bifrost X-Virus-Status: Clean On Sat, 29 Mar 2008 17:18:24 +0100 Anthony Charles wrote: > I think there is a problem with the new #c flag: > > zsh -f > Saito% setopt extendedglob > Saito% touch test.{zsh,ksh,bash} > Saito% print *.?(#c1)sh > test.ksh test.zsh > Saito% print *.?(#c2)sh > test.bash > Saito% print *.?(#c1,2)sh > test.bash > Saito% print *.?(#c1,)sh > zsh: no matches found: *.?(#c1,)sh > Saito% print *.?(#c1,) > test.bash test.ksh test.zsh > Saito% > > It seems that #c flag is too greedy. Am I wrong? You're right: I missed out a save/restore of the test string because I didn't have the right tests. The effect was that although #c correctly tried to match greedily first, it didn't backtrack along the test string on a failure. Index: Misc/globtests =================================================================== RCS file: /cvsroot/zsh/zsh/Misc/globtests,v retrieving revision 1.6 diff -u -r1.6 globtests --- Misc/globtests 27 Jul 2007 21:51:33 -0000 1.6 +++ Misc/globtests 30 Mar 2008 22:03:07 -0000 @@ -192,5 +192,20 @@ t froofroo (fro(#c2))(#c2) f froofroofroo (fro(#c2))(#c2) f froofro (fro(#c2))(#c2) +t ax ?(#c1,2)x +t ax ?(#c1,)x +t ax ?(#c0,1)x +f ax ?(#c0,0)x +f ax ?(#c2,)x +t aa a(#c1,2)a +t aa a(#c1,)a +t aa a(#c0,1)a +f aa a(#c0,0)a +f aa a(#c2,)a +t test.zsh *.?(#c1)sh +t test.bash *.?(#c2)sh +t test.bash *.?(#c1,2)sh +t test.bash *.?(#c1,)sh +t test.zsh *.?(#c1,)sh EOT print "$failed tests failed." Index: Src/pattern.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/pattern.c,v retrieving revision 1.42 diff -u -r1.42 pattern.c --- Src/pattern.c 25 Mar 2008 17:47:11 -0000 1.42 +++ Src/pattern.c 30 Mar 2008 22:03:08 -0000 @@ -2969,9 +2969,11 @@ scan[P_CT_PTR].p = (unsigned char *)patinput; if (max < 0 || cur < max) { + char *patinput_thistime = patinput; scan[P_CT_CURRENT].l = cur + 1; if (patmatch(scan + P_CT_OPERAND)) return 1; + patinput = patinput_thistime; } if (cur < min) return 0; Index: Test/D02glob.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/D02glob.ztst,v retrieving revision 1.13 diff -u -r1.13 D02glob.ztst --- Test/D02glob.ztst 27 Jul 2007 21:51:33 -0000 1.13 +++ Test/D02glob.ztst 30 Mar 2008 22:03:12 -0000 @@ -187,6 +187,21 @@ >0: [[ froofroo = (fro(#c2))(#c2) ]] >1: [[ froofroofroo = (fro(#c2))(#c2) ]] >1: [[ froofro = (fro(#c2))(#c2) ]] +>0: [[ ax = ?(#c1,2)x ]] +>0: [[ ax = ?(#c1,)x ]] +>0: [[ ax = ?(#c0,1)x ]] +>1: [[ ax = ?(#c0,0)x ]] +>1: [[ ax = ?(#c2,)x ]] +>0: [[ aa = a(#c1,2)a ]] +>0: [[ aa = a(#c1,)a ]] +>0: [[ aa = a(#c0,1)a ]] +>1: [[ aa = a(#c0,0)a ]] +>1: [[ aa = a(#c2,)a ]] +>0: [[ test.zsh = *.?(#c1)sh ]] +>0: [[ test.bash = *.?(#c2)sh ]] +>0: [[ test.bash = *.?(#c1,2)sh ]] +>0: [[ test.bash = *.?(#c1,)sh ]] +>0: [[ test.zsh = *.?(#c1,)sh ]] >0 tests failed. globtest globtests.ksh -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/