about summary refs log tree commit diff
path: root/Src/params.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/params.c')
-rw-r--r--Src/params.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/Src/params.c b/Src/params.c
index dbc6ce8d8..d60f91990 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -255,7 +255,11 @@ static Param argvparam;
 /* hash table containing the parameters */
  
 /**/
-HashTable paramtab;
+HashTable paramtab, realparamtab;
+
+#ifndef DYNAMIC
+#define getparamnode gethashnode2
+#endif /* DYNAMIC */
 
 /**/
 HashTable
@@ -267,8 +271,8 @@ newparamtable(int size, char const *name)
     ht->emptytable  = emptyhashtable;
     ht->filltable   = NULL;
     ht->addnode     = addhashnode;
-    ht->getnode     = gethashnode2;
-    ht->getnode2    = gethashnode2;
+    ht->getnode     = getparamnode;
+    ht->getnode2    = getparamnode;
     ht->removenode  = removehashnode;
     ht->disablenode = NULL;
     ht->enablenode  = NULL;
@@ -278,6 +282,25 @@ newparamtable(int size, char const *name)
     return ht;
 }
 
+#ifdef DYNAMIC
+/**/
+static HashNode
+getparamnode(HashTable ht, char *nam)
+{
+    HashNode hn = gethashnode2(ht, nam);
+    Param pm = (Param) hn;
+
+    if (pm && pm->u.str && (pm->flags & PM_AUTOLOAD)) {
+	char *mn = dupstring(pm->u.str);
+
+	if (!load_module(mn))
+	    return NULL;
+	hn = gethashnode2(ht, nam);
+    }
+    return hn;
+}
+#endif /* DYNAMIC */
+
 /* Copy a parameter hash table */
 
 static HashTable outtable;
@@ -402,7 +425,7 @@ createparamtable(void)
     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++)
@@ -542,7 +565,9 @@ createparam(char *name, int flags)
     Param pm, oldpm;
 
     if (name != nulstring) {
-	oldpm = (Param) paramtab->getnode(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)) {
@@ -2703,6 +2728,8 @@ printparamnode(HashNode hn, int printflags)
 
     /* Print the attributes of the parameter */
     if (printflags & PRINT_TYPE) {
+	if (p->flags & PM_AUTOLOAD)
+	    printf("undefined ");
 	if (p->flags & PM_INTEGER)
 	    printf("integer ");
 	else if (p->flags & PM_ARRAY)
@@ -2736,6 +2763,11 @@ printparamnode(HashNode hn, int printflags)
     }
 
     quotedzputs(p->nam, stdout);
+
+    if (p->flags & PM_AUTOLOAD) {
+	putchar('\n');
+	return;
+    }
     if (printflags & PRINT_KV_PAIR)
 	putchar(' ');
     else