From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3310 invoked from network); 18 Apr 2001 20:47:27 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Apr 2001 20:47:27 -0000 Received: (qmail 29888 invoked by alias); 18 Apr 2001 20:47:20 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14016 Received: (qmail 29871 invoked from network); 18 Apr 2001 20:47:19 -0000 From: "Bart Schaefer" Message-Id: <1010418201441.ZM8481@candle.brasslantern.com> Date: Wed, 18 Apr 2001 20:14:41 +0000 In-Reply-To: <1010418172622.ZM30038@candle.brasslantern.com> Comments: In reply to "Bart Schaefer" "Re: Patterns quoting in subscript (was: Re: PATCH: Assorted parameter stuff)" (Apr 18, 5:26pm) References: <1010418172622.ZM30038@candle.brasslantern.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Subject: Re: Patterns quoting in subscript (was: Re: PATCH: Assorted parameter stuff) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 18, 5:26pm, Bart Schaefer wrote: } } [...] So if you want to match 4 backslashes, you need 16 backslashes; } but if you want to match 4 backslashes followed by a literal question } mark, you need a whopping 34 backslashes, because you have to double } all 16 of those backslashes and then add two more to quote the `?' } itself. } } Clearly this is silly; it results because of the extra call to } parsestr() that happens when the `needtok' loop in getarg() detects an } ispecial() (the `?' in this example). I'll see if that can't be made } to behave a bit more intelligibly. By relocating one remnulargs() call relative to 14008 and removing one INULL() "optimization", it's possible to get a consistent 4-to-1 ratio of backslashes in the input subscript to match one backslash in the array value by pattern match. That applies only with (i) (I) (r) (R); it's the usual 2-to-1 ratio for a direct associative-array lookup. The following goes on top of 14008. --- current/Src/params.c Tue Apr 17 23:30:50 2001 +++ ../zsh-4.0/Src/params.c Wed Apr 18 11:56:33 2001 @@ -919,22 +919,19 @@ i++; else if (c == Outbrack) i--; - if (INULL(c)) { - if (!*++t) - break; - } else if (ispecial(c)) + if (ispecial(c)) needtok = 1; } if (!c) return 0; s = dupstrpfx(s, t - s); - remnulargs(s); *str = tt = t; if (needtok) { if (parsestr(s)) return 0; singsub(&s); } + remnulargs(s); if (!rev) { if (ishash) { HashTable ht = v->pm->gets.hfn(v->pm); @@ -942,7 +939,6 @@ ht = newparamtable(17, v->pm->nam); v->pm->sets.hfn(v->pm, ht); } - remnulargs(s); untokenize(s); if (!(v->pm = (Param) ht->getnode(ht, s))) { HashTable tht = paramtab; -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net