From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21962 invoked from network); 30 May 2007 12:54:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.0 (2007-05-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=no version=3.2.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 30 May 2007 12:54:59 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 19429 invoked from network); 30 May 2007 12:54:54 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 May 2007 12:54:54 -0000 Received: (qmail 22904 invoked by alias); 30 May 2007 12:54:51 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23500 Received: (qmail 22895 invoked from network); 30 May 2007 12:54:51 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 30 May 2007 12:54:51 -0000 Received: (qmail 19117 invoked from network); 30 May 2007 12:54:51 -0000 Received: from cluster-d.mailcontrol.com (217.69.20.190) by a.mx.sunsite.dk with SMTP; 30 May 2007 12:54:47 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly45d.srv.mailcontrol.com (MailControl) with ESMTP id l4UCsGxf020543 for ; Wed, 30 May 2007 13:54:39 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Wed, 30 May 2007 13:54:37 +0100 Date: Wed, 30 May 2007 13:54:36 +0100 From: Peter Stephenson To: "zsh workers" Subject: Re: Change in FIGNORE behavior Message-ID: <20070530135436.410e11ff@news01.csr.com> In-Reply-To: <200705301127.l4UBROR5010814@news01.csr.com> References: <20a807210705291856qe306eeds250f4f9d5f4dd33f@mail.gmail.com> <200705300945.l4U9jUbE009607@news01.csr.com> <20070530112934.3950357b@news01.csr.com> <070530035810.ZM29792@torch.brasslantern.com> <200705301127.l4UBROR5010814@news01.csr.com> Organization: CSR X-Mailer: Claws Mail 2.9.1 (GTK+ 2.10.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 30 May 2007 12:54:37.0060 (UTC) FILETIME=[ADB94C40:01C7A2B9] X-Scanned-By: MailControl A-07-07-05 (www.mailcontrol.com) on 10.68.0.155 On Wed, 30 May 2007 12:27:24 +0100 Peter Stephenson wrote: > It would be nice to be able to detect if the index is going to be used > for something other than extracting a single element and use the first > index if so, but the current interface doesn't make that easy. This would do it, but we're now disappearing back down the hole we've supposedly dug ourselves out of. Index: Doc/Zsh/params.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/params.yo,v retrieving revision 1.37 diff -u -r1.37 params.yo --- Doc/Zsh/params.yo 21 May 2007 09:30:25 -0000 1.37 +++ Doc/Zsh/params.yo 30 May 2007 12:50:00 -0000 @@ -234,7 +234,10 @@ Like `tt(r)', but gives the last match. For associative arrays, gives all possible matches. May be used for assigning to ordinary array elements, but not for assigning to associative arrays. -On failure the empty string is returned. +On failure the empty string is returned for a single match; any +time a valid subscript is needed (for example, on an assignment +to a failed element, or in a subscript range) the subscript is +treated as the location of the first element. ) item(tt(i))( Like `tt(r)', but gives the index of the match instead; this may not be Index: Src/params.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/params.c,v retrieving revision 1.129 diff -u -r1.129 params.c --- Src/params.c 29 May 2007 14:16:03 -0000 1.129 +++ Src/params.c 30 May 2007 12:50:07 -0000 @@ -976,6 +976,9 @@ * *w is only set if we need to find the end of a word (input; should * be set to 0 by the caller). * + * flags is the current set of SCANPM_ flags passed down from + * the substitution being done. + * * The final two arguments are to support multibyte characters. * If supplied they are set to the length of the character before * the index position and the one at the index position. If @@ -991,7 +994,7 @@ /**/ static zlong -getarg(char **str, int *inv, Value v, int a2, zlong *w, +getarg(char **str, int *inv, Value v, int a2, zlong *w, int flags, int *prevcharlen, int *nextcharlen) { int hasbeg = 0, word = 0, rev = 0, ind = 0, down = 0, l, i, ishash; @@ -1324,11 +1327,16 @@ * is ambiguous with KSH_ARRAYS set, but we're * stuck with that now. * - * If the index is to be turned into an element, - * return an index that does not point to a valid + * If + * - the index is to be turned into an element + * - we are not in a range of indices, i.e. neither + * a comma follows nor SCANPM_ENDRANGE is set, + * - we are not assigning, + * then return an index that does not point to a valid * element (since 0 is treated the same as 1). */ - if (!ind) + if (!ind && *t != ',' && + !(flags & (SCANPM_ENDRANGE|SCANPM_ASSIGNING))) r = len + 1; } else for (r = 1 + beg, p = ta + beg; *p; r++, p++) @@ -1555,7 +1563,9 @@ * its index, ensure the element is empty. * See comments on the array case above. */ - return (down && ind) ? 0 : slen + 1; + return (down && (ind || *t == '.' || + (flags & (SCANPM_ENDRANGE|SCANPM_ASSIGNING)))) + ? 0 : slen + 1; } } return r; @@ -1563,13 +1573,14 @@ /**/ int -getindex(char **pptr, Value v, int dq) +getindex(char **pptr, Value v, int flags) { int start, end, inv = 0; char *s = *pptr, *tbrack; *s++ = '['; - s = parse_subscript(s, dq); /* Error handled after untokenizing */ + /* Error in parsing handled after untokenizing */ + s = parse_subscript(s, flags & SCANPM_DQUOTED); /* Now we untokenize everything except inull() markers so we can check * * for the '*' and '@' special subscripts. The inull()s are removed * * in getarg() after we know whether we're doing reverse indexing. */ @@ -1598,7 +1609,8 @@ zlong we = 0, dummy; int startprevlen, startnextlen; - start = getarg(&s, &inv, v, 0, &we, &startprevlen, &startnextlen); + start = getarg(&s, &inv, v, 0, &we, flags, + &startprevlen, &startnextlen); if (inv) { if (!v->isarr && start != 0) { @@ -1672,7 +1684,8 @@ if ((com = (*s == ','))) { s++; - end = getarg(&s, &inv, v, 1, &dummy, NULL, NULL); + end = getarg(&s, &inv, v, 1, &dummy, + flags | SCANPM_ENDRANGE, NULL, NULL); } else { end = we ? we : start; } @@ -1790,7 +1803,7 @@ v->start = 0; v->end = -1; if (bracks > 0 && (*s == '[' || *s == Inbrack)) { - if (getindex(&s, v, (flags & SCANPM_DQUOTED))) { + if (getindex(&s, v, flags)) { *pptr = s; return v; } Index: Src/subst.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/subst.c,v retrieving revision 1.77 diff -u -r1.77 subst.c --- Src/subst.c 2 Apr 2007 11:00:43 -0000 1.77 +++ Src/subst.c 30 May 2007 12:50:10 -0000 @@ -2008,7 +2008,7 @@ v->isarr = isarr; v->pm = pm; v->end = -1; - if (getindex(&s, v, qt) || s == os) + if (getindex(&s, v, qt ? SCANPM_DQUOTED : 0) || s == os) break; } /* Index: Src/zsh.h =================================================================== RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v retrieving revision 1.115 diff -u -r1.115 zsh.h --- Src/zsh.h 28 May 2007 22:57:41 -0000 1.115 +++ Src/zsh.h 30 May 2007 12:50:12 -0000 @@ -1422,6 +1422,7 @@ #define SCANPM_ASSIGNING (1<<6) #define SCANPM_KEYMATCH (1<<7) #define SCANPM_DQUOTED (1<<8) +#define SCANPM_ENDRANGE (1<<9) #define SCANPM_ISVAR_AT ((-1)<<15) /* Only sign bit is significant */ /* -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview