From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16176 invoked from network); 21 May 2003 16:03:51 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 21 May 2003 16:03:51 -0000 Received: (qmail 20413 invoked by alias); 21 May 2003 16:03:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18565 Received: (qmail 20382 invoked from network); 21 May 2003 16:03:44 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 21 May 2003 16:03:44 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [62.189.183.235] by sunsite.dk (MessageWall 1.0.8) with SMTP; 21 May 2003 16:3:43 -0000 Received: from exchange01.csr.com (unverified) by (Content Technologies SMTPRS 4.2.1) with ESMTP id for ; Wed, 21 May 2003 17:13:49 +0100 Received: from csr.com (tinky-winky.csr.com [192.168.144.127]) by exchange01.csr.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id LKHGJQP9; Wed, 21 May 2003 17:04:17 +0100 To: zsh-workers@sunsite.dk Subject: Re: segfault in 4.1.1-test-2 with ${(u)${=:-$(echo yes yes)}} In-reply-to: "Anthony Heading"'s message of "Thu, 22 May 2003 00:26:37 +0900." <20030521152637.GA7954@tkd-fires-02.ja.jpmorgan.com> Date: Wed, 21 May 2003 17:03:39 +0100 Message-ID: <20313.1053533019@csr.com> From: Peter Stephenson I could add comments about this, but why start now? The whole of paramsubst() needs to be something else entirely. I *hate* that function. Index: Src/subst.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/subst.c,v retrieving revision 1.32 diff -u -r1.32 subst.c --- Src/subst.c 7 May 2003 09:38:53 -0000 1.32 +++ Src/subst.c 21 May 2003 15:59:49 -0000 @@ -1951,24 +1951,31 @@ int i; LinkNode on = n; - if (!aval[0] && !plan9) { + if (unique) { + if(!copied) + aval = arrdup(aval); + + i = arrlen(aval); + if (i > 1) + zhuniqarray(aval); + } + if ((!aval[0] || !aval[1]) && !plan9) { + int vallen; if (aptr > (char *) getdata(n) && aptr[-1] == Dnull && *fstr == Dnull) *--aptr = '\0', fstr++; - y = (char *) hcalloc((aptr - ostr) + strlen(fstr) + 1); + vallen = aval[0] ? strlen(aval[0]) : 0; + y = (char *) hcalloc((aptr - ostr) + vallen + strlen(fstr) + 1); strcpy(y, ostr); *str = y + (aptr - ostr); + if (vallen) + { + strcpy(*str, aval[0]); + *str += vallen; + } strcpy(*str, fstr); setdata(n, y); return n; - } - if (unique) { - if(!copied) - aval = arrdup(aval); - - i = arrlen(aval); - if (i > 1) - zhuniqarray(aval); } if (sortit) { if (!copied) Index: Test/D04parameter.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v retrieving revision 1.8 diff -u -r1.8 D04parameter.ztst --- Test/D04parameter.ztst 7 May 2003 09:38:53 -0000 1.8 +++ Test/D04parameter.ztst 21 May 2003 15:59:49 -0000 @@ -589,3 +589,13 @@ 0:Parameters associated with (#m) flag >MATCH 16 20 MATCH >5 + + 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 +>JAMESyesJOYCE +>JAMESyes +>she +>said +>i +>willJOYCE -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. **********************************************************************