From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: PATCH: parameter module
Date: Sat, 15 May 1999 16:40:12 +0200 [thread overview]
Message-ID: <9905151440.AA37734@ibmth.df.unipi.it> (raw)
I spotted some problems with the parameter module.
1. If you call zmodload from a function, the parameters got loaded into
local scope. Since I use a function load() which calls zmodload, this
confused me. As the scope of the zmodload is not local, and there is no
typeset to make them appear in local scope, I presume this was not the
intention, but maybe I was wrong. It might be possible to do some typeset
trickery so that `typeset parameters' gets the parameters special variable
loaded into local scope. At the moment, I shudder to think what effect
this has(*), but I put a debugging test in createparam() for parameters
that didn't get deleted properly from a local scope.
(*) I thought createparam() was supposed to fail if you did this, and hence
createspecialparam() also, but that doesn't seem to happen. I don't dare
look at this in case it's a bug.
2. When unloading, $parameters was readonly and complained about it.
3. Trivial fix for a compiler warning about unitialized variables. I also
added a debugging check for unhandled parameter types: you never know when
someone's going to change the shell and forget the parameter module.
--- Src/Modules/parameter.c.pm Thu May 13 17:45:44 1999
+++ Src/Modules/parameter.c Sat May 15 16:19:37 1999
@@ -50,7 +50,7 @@
if (!(pm = createparam(name, PM_SPECIAL|PM_REMOVABLE|PM_HASHED)))
return NULL;
- pm->level = locallevel;
+ pm->level = pm->old ? locallevel : 0;
pm->gets.hfn = hashgetfn;
pm->sets.hfn = hashsetfn;
pm->unsetfn = stdunsetfn;
@@ -79,7 +79,7 @@
static char *
paramtypestr(Param pm)
{
- char *val;
+ char *val = NULL;
int f = pm->flags;
if (!(f & PM_UNSET)) {
@@ -89,6 +89,7 @@
case PM_INTEGER: val = "integer"; break;
case PM_HASHED: val = "association"; break;
}
+ DPUTS(!val, "BUG: type not handled in parameter");
val = dupstring(val);
if (f & PM_LEFT)
val = dyncat(val, "-left");
@@ -638,8 +639,10 @@
/* Remove the special parameters if they are still the same. */
- if ((pm = (Param) paramtab->getnode(paramtab, PAR_NAM)) && pm == parpm)
+ if ((pm = (Param) paramtab->getnode(paramtab, PAR_NAM)) && pm == parpm) {
+ pm->flags &= ~PM_READONLY;
unsetparam_pm(pm, 0, 1);
+ }
if ((pm = (Param) paramtab->getnode(paramtab, CMD_NAM)) && pm == cmdpm)
unsetparam_pm(pm, 0, 1);
if ((pm = (Param) paramtab->getnode(paramtab, FUN_NAM)) && pm == funpm)
--- Src/params.c.pm Thu May 13 17:45:43 1999
+++ Src/params.c Sat May 15 16:27:47 1999
@@ -572,6 +572,8 @@
gethashnode2(paramtab, name) :
paramtab->getnode(paramtab, name));
+ DPUTS(oldpm && oldpm->level > locallevel,
+ "BUG: old local parameter not deleteed");
if (oldpm && oldpm->level == locallevel) {
if (!(oldpm->flags & PM_UNSET) || (oldpm->flags & PM_SPECIAL)) {
oldpm->flags &= ~PM_UNSET;
--
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
next reply other threads:[~1999-05-15 15:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-05-15 14:40 Peter Stephenson [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-09-16 12:15 Sven Wischnowsky
1999-05-12 8:51 Sven Wischnowsky
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=9905151440.AA37734@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).