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

Re: PATCH: autoloaded parameters



I wrote:

>   - To avoid having a `local' with the name of a parameter that will
>     be autoloaded trigger the loading of the module, I had to change
>     calls like `paramtab->getnode()' to `gethashnode2(paramtab,...)'
>     in some places. This is ugly. Maybe we should keep a second
>     pointer to the real paramtab and do this only if
>     `paramtab == realparamtab'. Any comments?

The patch below makes this change.

[This might have caused problems once we have special associative
arrays that use a hashtable with their own functions. In that case the 
normal hashtable.c-function would have been called instead of the one
defined in the table.]

Did anyone find the time to try this?

Bye
 Sven

diff -u os/builtin.c Src/builtin.c
--- os/builtin.c	Wed Apr 28 16:24:08 1999
+++ Src/builtin.c	Thu Apr 29 11:52:32 1999
@@ -1793,7 +1793,9 @@
 	    continue;
 	}
 	if (!typeset_single(name, asg->name,
-			    (Param)gethashnode2(paramtab, asg->name),
+			    (Param) (paramtab == realparamtab ?
+				     gethashnode2(paramtab, asg->name) :
+				     paramtab->getnode(paramtab, asg->name)),
 			    func, on, off, roff, asg->value, NULL))
 	    returnval = 1;
     }
@@ -1974,7 +1976,9 @@
 	    }
 	    *ss = 0;
 	}
-	pm = (Param) gethashnode2(paramtab, s);
+	pm = (Param) (paramtab == realparamtab ?
+		      gethashnode2(paramtab, s) :
+		      paramtab->getnode(paramtab, s));
 	if (!pm)
 	    returnval = 1;
 	else if ((pm->flags & PM_RESTRICTED) && isset(RESTRICTED)) {
diff -u os/params.c Src/params.c
--- os/params.c	Wed Apr 28 16:24:11 1999
+++ Src/params.c	Thu Apr 29 11:51:04 1999
@@ -255,7 +255,7 @@
 /* hash table containing the parameters */
  
 /**/
-HashTable paramtab;
+HashTable paramtab, realparamtab;
 
 /**/
 HashTable
@@ -419,7 +419,7 @@
     char buf[50], *str, *iname;
     int num_env;
 
-    paramtab = newparamtable(151, "paramtab");
+    paramtab = realparamtab = newparamtable(151, "paramtab");
 
     /* Add the special parameters to the hash table */
     for (ip = special_params; ip->nam; ip++)
@@ -559,7 +559,9 @@
     Param pm, oldpm;
 
     if (name != nulstring) {
-	oldpm = (Param) gethashnode2(paramtab, name);
+	oldpm = (Param) (paramtab == realparamtab ?
+			 gethashnode2(paramtab, name) :
+			 paramtab->getnode(paramtab, name));
 
 	if (oldpm && oldpm->level == locallevel) {
 	    if (!(oldpm->flags & PM_UNSET) || (oldpm->flags & PM_SPECIAL)) {

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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