From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10604 invoked from network); 10 May 2000 19:08:11 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 10 May 2000 19:08:11 -0000 Received: (qmail 15077 invoked by alias); 10 May 2000 19:07:57 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11314 Received: (qmail 15057 invoked from network); 10 May 2000 19:07:56 -0000 To: zsh-workers@sunsite.auc.dk Subject: Re: `typeset -U' and exported tied parameters In-reply-to: ""Bart Schaefer""'s message of "Wed, 10 May 2000 15:59:24 -0000." <1000510155924.ZM10248@candle.brasslantern.com> Date: Wed, 10 May 2000 20:07:55 +0100 From: Peter Stephenson Message-Id: "Bart Schaefer" wrote: > Note that although `typeset -U' has changed both the array and the tied > parameter, it has failed to update the exported copy of the tied parameter. This is the easy fix. This is similar to the same problem with lower/uppercasing of parameter. I didn't look further because we sort of agreed that parameter getting and setting could do with a complete rewrite. (The number of things we've agreed over the years could do with a complete rewrite is large. It's an immensely satisfying and timesaving thing to do. Unfortunately it doesn't get anything fixed.) The change to uniqarray() is just because no-one was using the return value. Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.14 diff -u -r1.14 builtin.c --- Src/builtin.c 2000/05/05 07:42:36 1.14 +++ Src/builtin.c 2000/05/10 19:04:25 @@ -1607,11 +1607,20 @@ } if ((on & PM_UNIQUE) && !(pm->flags & PM_READONLY & ~off)) { Param apm; - if (PM_TYPE(pm->flags) == PM_ARRAY) - uniqarray((*pm->gets.afn) (pm)); - else if (PM_TYPE(pm->flags) == PM_SCALAR && pm->ename && - (apm = (Param) paramtab->getnode(paramtab, pm->ename))) - uniqarray((*apm->gets.afn) (apm)); + char **x; + if (PM_TYPE(pm->flags) == PM_ARRAY) { + x = (*pm->gets.afn)(pm); + uniqarray(x); + if (pm->ename && x) + arrfixenv(pm->ename, x); + } else if (PM_TYPE(pm->flags) == PM_SCALAR && pm->ename && + (apm = + (Param) paramtab->getnode(paramtab, pm->ename))) { + x = (*apm->gets.afn)(apm); + uniqarray(x); + if (x) + arrfixenv(pm->nam, x); + } } pm->flags = (pm->flags | on) & ~(off | PM_UNSET); /* This auxlen/pm->ct stuff is a nasty hack. */ Index: Src/params.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/params.c,v retrieving revision 1.7 diff -u -r1.7 params.c --- Src/params.c 2000/04/27 08:21:10 1.7 +++ Src/params.c 2000/05/10 19:04:35 @@ -2299,10 +2299,9 @@ } /**/ -int +void uniqarray(char **x) { - int changes = 0; char **t, **p = x; if (!x || !*x) @@ -2312,10 +2311,8 @@ if (!strcmp(*p, *t)) { zsfree(*p); for (t = p--; (*t = t[1]) != NULL; t++); - changes++; break; } - return changes; } /* Function to get value of special parameter `#' and `ARGC' */ @@ -2759,7 +2756,7 @@ * do the replacing, since we've already scanned for the string. */ /**/ -static void +void arrfixenv(char *s, char **t) { char **ep, *u; -- Peter Stephenson Work: pws@CambridgeSiliconRadio.com Web: http://www.pwstephenson.fsnet.co.uk