Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: parameter module
- X-seq: zsh-workers 6290
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: parameter module
- Date: Sat, 15 May 1999 16:40:12 +0200
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
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@xxxxxxxxxxxxxxxxx> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
Messages sorted by:
Reverse Date,
Date,
Thread,
Author