zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: 3.1.5-pws-N: unset fix
@ 1999-05-07 13:40 Peter Stephenson
  1999-05-31  1:28 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 1999-05-07 13:40 UTC (permalink / raw)
  To: Zsh hackers list

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 <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PATCH: 3.1.5-pws-N: unset fix
  1999-05-07 13:40 PATCH: 3.1.5-pws-N: unset fix Peter Stephenson
@ 1999-05-31  1:28 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1999-05-31  1:28 UTC (permalink / raw)
  To: Peter Stephenson, Zsh hackers list

On May 7,  3:40pm, Peter Stephenson wrote:
} Subject: PATCH: 3.1.5-pws-N: unset fix
}
} The first hunk of this is relevant to 3.0.6, although the if (pm->flags &
} PM_UNSET) test needs adding by hand.

Are you sure this is relevant to 3.0.6?  As far as I know, prior to the
associative array changes in 3.1.5+ parameters with PM_UNSET were never
permitted to appear in the paramtab.  (So the 3.1.5+ bug is probably my
fault for missing a spot where PM_UNSET needed to be tested.)

} [...] in 3.0.6 [...] 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 [...] which may not be intended [...]
} so it may be a bug.  Should I send a patch for both for 3.0.6?

You should either send a patch or make mention of the difference in the
FAQ somewhere, or perhaps both.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-05-31  1:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-07 13:40 PATCH: 3.1.5-pws-N: unset fix Peter Stephenson
1999-05-31  1:28 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).