From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25862 invoked from network); 24 Jun 1999 15:37:10 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 24 Jun 1999 15:37:10 -0000 Received: (qmail 23932 invoked by alias); 24 Jun 1999 15:37:04 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6830 Received: (qmail 23904 invoked from network); 24 Jun 1999 15:36:08 -0000 From: "Bart Schaefer" Message-Id: <990624153603.ZM1719@candle.brasslantern.com> Date: Thu, 24 Jun 1999 15:36:03 +0000 In-Reply-To: <9906231002.AA17151@ibmth.df.unipi.it> Comments: In reply to Peter Stephenson "Re: Possible bug with ${(A)foo=} and ${(AA)foo=}" (Jun 23, 12:02pm) References: <9906231002.AA17151@ibmth.df.unipi.it> X-Mailer: Z-Mail (5.0.0 30July97) To: "ZSH workers mailing list" Subject: PATCH: Re: Possible bug with ${(A)foo=} and ${(AA)foo=} MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jun 23, 12:02pm, Peter Stephenson wrote: } Subject: Re: Possible bug with ${(A)foo=} and ${(AA)foo=} } } Without fixing the general array-splitting problem, which is difficult, I } don't see there's any problem deciding what to do in the case of an } associative array, since the intention in such a case can only be to create } an empty one because there is no key/value pair, even with ${(AA)foo=''} OK, then ... here's a companion patch which defers allocation of the hash table when there's nothing to put into it. Index: Src/params.c =================================================================== @@ -1898,7 +1898,7 @@ * since that could cause trouble for special hashes. This way, * * it's up to pm->sets.hfn() what to do. */ int alen = arrlen(val); - HashTable opmtab = paramtab, ht; + HashTable opmtab = paramtab, ht = 0; char **aptr = val; Value v = (Value) hcalloc(sizeof *v); v->b = -1; @@ -1909,7 +1909,8 @@ NULL, 0); return; } - ht = paramtab = newparamtable(17, pm->nam); + if (alen) + ht = paramtab = newparamtable(17, pm->nam); while (*aptr) { /* The parameter name is ztrdup'd... */ v->pm = createparam(*aptr, PM_SCALAR|PM_UNSET); -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com