From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1366 invoked from network); 7 May 1999 14:05:50 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 7 May 1999 14:05:50 -0000 Received: (qmail 218 invoked by alias); 7 May 1999 14:05:17 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6235 Received: (qmail 210 invoked from network); 7 May 1999 14:05:16 -0000 Message-Id: <9905071340.AA43256@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: PATCH: 3.1.5-pws-N: unset fix Date: Fri, 07 May 1999 15:40:56 +0200 From: Peter Stephenson This fixes the parameter bugs I reported yesterday: first, typeset -m restored unset parameters; second, global parameters didn't get removed from the parameter table by an unset inside a function (without a typeset, they will be restored as globals anyway, so this was definitely a bug). The first hunk of this is relevant to 3.0.6, although the if (pm->flags & PM_UNSET) test needs adding by hand. The second bug does not exist as such in 3.0.6 --- though I noticed that if a parameter that was local in one function is unset in a function called from that, it will be restored next time in global scope, in other words this: % fn2() { unset foo; } % fn1() { typeset foo=bar; fn2; foo=notbar; } % fn1 % print $foo notbar which may not be intended, and does not happen in 3.1.5++ (foo is restored at the level of fn1). It compares with % fn1() { typeset foo=bar; unset foo; foo=notbar; } % fn1 % print ${+foo} 0 so it may be a bug. Should I send a patch for both for 3.0.6? --- Src/builtin.c.unset Mon May 3 13:13:57 1999 +++ Src/builtin.c Fri May 7 15:16:54 1999 @@ -1768,7 +1768,8 @@ for (i = 0; i < paramtab->hsize; i++) { for (pm = (Param) paramtab->nodes[i]; pm; pm = (Param) pm->next) { - if ((pm->flags & PM_RESTRICTED) && isset(RESTRICTED)) + if (((pm->flags & PM_RESTRICTED) && isset(RESTRICTED)) || + (pm->flags & PM_UNSET)) continue; if (domatch(pm->nam, com, 0)) addlinknode(pmlist, pm); --- Src/params.c.unset Wed May 5 09:34:37 1999 +++ Src/params.c Fri May 7 15:20:08 1999 @@ -1755,7 +1755,7 @@ * Some specials, such as those used in zle, still need removing * from the parameter table; they have the PM_REMOVABLE flag. */ - if ((locallevel && locallevel >= pm->level) || + if ((pm->level && locallevel >= pm->level) || (pm->flags & (PM_SPECIAL|PM_REMOVABLE)) == PM_SPECIAL) return; -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy