From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15895 invoked from network); 12 Sep 2006 09:35:26 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.5 (2006-08-29) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 12 Sep 2006 09:35:26 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 81204 invoked from network); 12 Sep 2006 09:35:16 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Sep 2006 09:35:16 -0000 Received: (qmail 29259 invoked by alias); 12 Sep 2006 09:35:14 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22689 Received: (qmail 29250 invoked from network); 12 Sep 2006 09:35:13 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 12 Sep 2006 09:35:13 -0000 Received: (qmail 81000 invoked from network); 12 Sep 2006 09:35:13 -0000 Received: from cluster-d.mailcontrol.com (217.69.20.190) by a.mx.sunsite.dk with SMTP; 12 Sep 2006 09:35:13 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly26d.srv.mailcontrol.com (MailControl) with ESMTP id k8C9UYgI018916 for ; Tue, 12 Sep 2006 10:34:52 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Tue, 12 Sep 2006 10:34:20 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.4/8.13.4) with ESMTP id k8C9YKFZ004345 for ; Tue, 12 Sep 2006 10:34:20 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.13.4/8.13.4/Submit) with ESMTP id k8C9YJfc004342 for ; Tue, 12 Sep 2006 10:34:20 +0100 Message-Id: <200609120934.k8C9YJfc004342@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: Re: ${${~:-*}//(#m)*/$MATCH=$MATCH} fails In-reply-to: References: Date: Tue, 12 Sep 2006 10:34:19 +0100 From: Peter Stephenson X-OriginalArrivalTime: 12 Sep 2006 09:34:20.0450 (UTC) FILETIME=[9FDD2020:01C6D64E] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-07-04-01 (www.mailcontrol.com) on 10.68.0.136 "Nikolai Weibull" wrote: > Try the above with an echo. In zsh 4.3.2, this will give you an > illegal UTF-8 character, an equal sign, and another illegal UTF-8 > character. Is $MATCH accessing uninitialized memory? Or am I doing > something wrong? Neither: the pattern matcher is being passed a tokenized string as the test string for matching. This doesn't make sense, particularly since the pattern matcher assumes the string can be metafied, which is what is messing up the characters. The easy fix is just to untokenize all test strings at that point (the pattern string needs tokens, of course). This stops the "*" being active at that point, although it's eligible for the effect of a ~ in the context further out. What I mean is, % foo="* % print ${${~foo}/\*/*} * % print ${~foo/\*/*} I don't think that's unreasonable. Index: Src/subst.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/subst.c,v retrieving revision 1.57 diff -u -r1.57 subst.c --- Src/subst.c 10 Sep 2006 18:10:49 -0000 1.57 +++ Src/subst.c 12 Sep 2006 09:30:53 -0000 @@ -2257,15 +2257,28 @@ /* * Either loop over an array doing replacements or * do the replacment on a string. + * + * We need an untokenized value for matching. */ if (!vunset && isarr) { + char **ap; + if (!copied) { + aval = arrdup(aval); + copied = 1; + } + for (ap = aval; *ap; ap++) { + untokenize(*ap); + } getmatcharr(&aval, s, flags, flnum, replstr); - copied = 1; } else { if (vunset) val = dupstring(""); + if (!copied) { + val = dupstring(val); + copied = 1; + untokenize(val); + } getmatch(&val, s, flags, flnum, replstr); - copied = 1; } break; } Index: Test/D04parameter.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v retrieving revision 1.19 diff -u -r1.19 D04parameter.ztst --- Test/D04parameter.ztst 1 Aug 2006 17:16:43 -0000 1.19 +++ Test/D04parameter.ztst 12 Sep 2006 09:30:53 -0000 @@ -829,6 +829,10 @@ 0:(#m) flag with pure string >this 4 4 is 7 7 a s 11 11tring + print ${${~:-*}//(#m)*/$MATCH=$MATCH} +0:(#m) flag with tokenized input +>*=* + print -l JAMES${(u)${=:-$(echo yes yes)}}JOYCE print -l JAMES${(u)${=:-$(echo yes yes she said yes i will yes)}}JOYCE 0:Bug with (u) flag reducing arrays to one element -- 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