From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1804 invoked from network); 5 Sep 2009 19:07:45 -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 new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 5 Sep 2009 19:07:45 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 65305 invoked from network); 5 Sep 2009 19:07:33 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 5 Sep 2009 19:07:33 -0000 Received: (qmail 14111 invoked by alias); 5 Sep 2009 19:07:23 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27243 Received: (qmail 14089 invoked from network); 5 Sep 2009 19:07:22 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 5 Sep 2009 19:07:22 -0000 Received: from mtaout01-winn.ispmail.ntl.com (mtaout01-winn.ispmail.ntl.com [81.103.221.47]) by bifrost.dotsrc.org (Postfix) with ESMTP id A3AB9801E2BF for ; Sat, 5 Sep 2009 21:07:16 +0200 (CEST) Received: from aamtaout04-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20090905190715.CDEA6742.mtaout01-winn.ispmail.ntl.com@aamtaout04-winn.ispmail.ntl.com> for ; Sat, 5 Sep 2009 20:07:15 +0100 Received: from pws-pc ([82.6.98.90]) by aamtaout04-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20090905190715.CXNK22934.aamtaout04-winn.ispmail.ntl.com@pws-pc> for ; Sat, 5 Sep 2009 20:07:15 +0100 Date: Sat, 5 Sep 2009 20:07:03 +0100 From: Peter Stephenson To: Zsh list Subject: Re: bug in 'b' array parameter subscript flag Message-ID: <20090905200703.4cca1d21@pws-pc> In-Reply-To: <19105.40754.702800.164855@gargle.gargle.HOWL> References: <19105.40754.702800.164855@gargle.gargle.HOWL> X-Mailer: Claws Mail 3.7.2 (GTK+ 2.16.5; 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=_PJ8n6JzpPIA:10 a=0QhtZkFNAAAA:8 a=NLZqzBF-AAAA:8 a=3SrpqIRW8E9b2UJ9ykgA:9 a=V7D6DTd0gmCCND1TSeUA:7 a=u1YZdQdibkHpClBTC6YFZ0e-CEEA:4 a=KLYB3oV4TgcA:10 a=_dQi-Dcv4p4A:10 X-Virus-Scanned: ClamAV 0.94.2/9777/Sat Sep 5 00:17:01 2009 on bifrost X-Virus-Status: Clean On Fri, 4 Sep 2009 19:13:54 -0400 Greg Klanderman wrote: > when the 'b' flag is used with the 'i' flag, and there are no elements > to be searched, '0' is incorrectly returned rather than one plus the > array length: Index: Src/params.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/params.c,v retrieving revision 1.156 diff -u -r1.156 params.c --- Src/params.c 8 May 2009 14:30:35 -0000 1.156 +++ Src/params.c 5 Sep 2009 19:05:21 -0000 @@ -1345,6 +1345,11 @@ len = arrlen(ta); if (beg < 0) beg += len; + if (down) { + if (beg < 0) + return 0; + } else if (beg >= len) + return len + 1; if (beg >= 0 && beg < len) { if (down) { if (!hasbeg) @@ -1363,6 +1368,11 @@ len = arrlen(ta); if (beg < 0) beg += len; + if (down) { + if (beg < 0) + return 0; + } else if (beg >= len) + return len + 1; if (beg >= 0 && beg < len) { if (down) { if (!hasbeg) Index: Test/D04parameter.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v retrieving revision 1.37 diff -u -r1.37 D04parameter.ztst --- Test/D04parameter.ztst 5 Jun 2009 11:15:53 -0000 1.37 +++ Test/D04parameter.ztst 5 Sep 2009 19:05:21 -0000 @@ -998,6 +998,34 @@ >sunny >day +# ' emacs likes this close quote + + a=(sping spang spong bumble) + print ${a[(i)spong]} + print ${a[(i)spung]} + print ${a[(ib.1.)spong]} + print ${a[(ib.4.)spong]} + print ${a[(ib.10.)spong]} +0:In and out of range reverse matched indices without and with b: arrays +>3 +>5 +>3 +>5 +>5 + + a="thrimblewuddlefrong" + print ${a[(i)w]} + print ${a[(i)x]} + print ${a[(ib.3.)w]} + print ${a[(ib.10.)w]} + print ${a[(ib.30.)w]} +0:In and out of range reverse matched indices without and with b: strings +>9 +>20 +>9 +>20 +>20 + foo="line:with::missing::fields:in:it" print -l ${(s.:.)foo} 0:Removal of empty fields in unquoted splitting -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/