From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17100 invoked from network); 29 Apr 1999 10:21:35 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 29 Apr 1999 10:21:35 -0000 Received: (qmail 10279 invoked by alias); 29 Apr 1999 10:00:59 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6153 Received: (qmail 10271 invoked from network); 29 Apr 1999 10:00:55 -0000 Date: Thu, 29 Apr 1999 12:00:39 +0200 (MET DST) Message-Id: <199904291000.MAA20123@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Sven Wischnowsky's message of Wed, 28 Apr 1999 11:51:11 +0200 (MET DST) Subject: 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@informatik.hu-berlin.de