zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@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	[thread overview]
Message-ID: <9905071340.AA43256@ibmth.df.unipi.it> (raw)

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


             reply	other threads:[~1999-05-07 14:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-07 13:40 Peter Stephenson [this message]
1999-05-31  1:28 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9905071340.AA43256@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).