PATCH: avoid problem with deleting nameref features in modules

Mikael Magnusson <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
The old code fixes the specific case of zmodload -u zsh/ksh93 but:
% zmodload zsh/ksh93
% echo ${.sh.version}
zsh-5.9.0.3-test-319-g21367ac
% zmodload -F zsh/ksh93 -p:.sh.version
zsh/ksh93: parameter `.sh.version' already deleted
% echo $ZSH_PATCHLEVEL
zsh-5.9.0.3-test-319-g21367ac

This output is pretty confusing until you realize what's going on.
(Which is that deleteparamdef checks if (searchpm == d->pm), fails
because it followed a nameref, and then doesn't delete anything).

By using getnode2 instead, we avoid the problem at the source.
---

I know that nameref stuff is up in the air at the moment, but is there any reason not
to do this?

 Src/Modules/ksh93.c | 8 --------
 Src/module.c        | 2 +-
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/Src/Modules/ksh93.c b/Src/Modules/ksh93.c
index 159a4fe7cf..e70c20d715 100644
--- a/Src/Modules/ksh93.c
+++ b/Src/Modules/ksh93.c
@@ -270,14 +270,6 @@ cleanup_(Module m)
 
     deletewrapper(m, wrapper);
 
-    /* Clean up namerefs, otherwise deleteparamdef() is confused */
-    for (p = partab; p < partab + sizeof(partab)/sizeof(*partab); ++p) {
-	if (p->flags & PM_NAMEREF) {
-	    HashNode hn = gethashnode2(paramtab, p->name);
-	    if (hn)
-		((Param)hn)->node.flags &= ~PM_NAMEREF;
-	}
-    }
     return setfeatureenables(m, &module_features, NULL);
 }
 
diff --git a/Src/module.c b/Src/module.c
index 5652a123ee..83a518c442 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -1127,7 +1127,7 @@ addparamdef(Paramdef d)
 int
 deleteparamdef(Paramdef d)
 {
-    Param pm = (Param) paramtab->getnode(paramtab, d->name);
+    Param pm = (Param) paramtab->getnode2(paramtab, d->name);
 
     if (!pm)
 	return 1;
-- 
2.38.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.