From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 573 invoked from network); 8 Oct 2002 10:02:21 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 8 Oct 2002 10:02:21 -0000 Received: (qmail 14969 invoked by alias); 8 Oct 2002 10:02:12 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17792 Received: (qmail 14931 invoked from network); 8 Oct 2002 10:02:10 -0000 X-VirusChecked: Checked From: Oliver Kiddle To: Zsh workers Subject: PATCH: tied parameters bug MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25421.1034071286.1@logica.com> Date: Tue, 08 Oct 2002 11:01:40 +0100 Sender: kiddleo@logica.com Message-Id: I noticed this bug while looking at aspects of the parameter code: % g() { > local SC="hello" > unset sc > } % typeset -T SC sc % g Tied parameters use pm->ename to store the name of the parameter they are tied to in string form. So in this code, it unsets the local instead of the global SC. As a result, the global SC still exists and if used, fairly shortly results in a seg fault. The same problem applies the other way around (unsetting the scalar with a local array). The fix below relies on the tied parameters being at the same local level (which I believe always holds true). It makes the code search for the parameter at the correct local level and then unsets it which requires a nasty hack to avoid the parameter node being removed from the table. Oliver Index: Src/params.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/params.c,v retrieving revision 1.65 diff -u -r1.65 params.c --- Src/params.c 5 Aug 2002 12:36:00 -0000 1.65 +++ Src/params.c 8 Oct 2002 09:26:44 -0000 @@ -2234,8 +2234,21 @@ /* remove it under its alternate name if necessary */ if (pm->ename && !altflag) { altpm = (Param) paramtab->getnode(paramtab, pm->ename); - if (altpm) + /* tied parameters are at the same local level as each other */ + oldpm = NULL; + while (altpm && altpm->level > pm->level) { + /* param under alternate name hidden by a local */ + oldpm = altpm; + altpm = altpm->old; + } + if (altpm) { + if (oldpm) { + oldpm->old = altpm->old; + /* fudge things so removenode isn't called */ + altpm->level = locallevel; + } unsetparam_pm(altpm, 1, exp); + } } /* This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.