Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Eliminate getparamnode() and the distinction between getnode() and getnode2()



diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index e8a6b6422..0ac758fbe 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -1082,7 +1082,7 @@ do_single(Cmatch m)
  } else
     n = p + 1;

- if ((pm = (Param) realparamtab->getnode(realparamtab, n)) &&
+ if ((pm = resolveparam(n, 1)) ||
     PM_TYPE(pm->node.flags) != PM_SCALAR)
     tryit = 0;
     }

This will surely crash when pm is NULL and you access pm->node?


On Thu, Sep 10, 2026 at 11:29 PM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> This patch uses the functions newly introduced by workers/55145 to replace all [real]paramtab->getnode() and ->getnode2() calls with calls to getparam(), loadparam(), and resolveparam() that explicitly state what is intended. Most tab->getnode(tab, name) calls are replaced with an equivalent resolveparam(name, /*load=*/1) call and most tab->getnode2(tab, name) calls with an equivalent getparam(name) call but some calls are replaced by calls that do slightly less or more than their equivalent call. For example, there are cases where there is no need to load the resolved parameter or cases where the looked up parameter should not only exist but also be one that is set. For an easier review, the different replacements are split into separate commits on GitHub.
>
> Once all getnode() calls have been replaced, there is no longer any need to have distinct getnode() and getnode2() functions for the parameter table. Both can use gethashnode2(), i.e., simply return the node/parameter with the requested name, and getparamnode() can be eliminated.
>
> - Eliminate getparamnode() and the distinction between getnode() and getnode2()
>   (depends on workers/55145)
>
> Philippe
>


--
Mikael Magnusson




Messages sorted by: Reverse Date, Date, Thread, Author