about summary refs log tree commit diff
path: root/Src/Modules
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-10-07 11:48:06 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-10-07 11:48:06 +0000
commit3ad5e3e7fefa823cb9b1186507999b0d5d9f3f2d (patch)
treeb0d163d90f22cee71b37479cdfee9caaf0b13c65 /Src/Modules
parent5445efbb914a49f49399117e73b0fbb439a25b82 (diff)
downloadzsh-3ad5e3e7fefa823cb9b1186507999b0d5d9f3f2d.tar.gz
zsh-3ad5e3e7fefa823cb9b1186507999b0d5d9f3f2d.tar.xz
zsh-3ad5e3e7fefa823cb9b1186507999b0d5d9f3f2d.zip
17481 (Karl Tomlinson): get/set for terminfo and termcap parameters
Diffstat (limited to 'Src/Modules')
-rw-r--r--Src/Modules/termcap.c22
-rw-r--r--Src/Modules/terminfo.c29
2 files changed, 33 insertions, 18 deletions
diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c
index 177a0d5c7..3b1e6e1e6 100644
--- a/Src/Modules/termcap.c
+++ b/Src/Modules/termcap.c
@@ -236,10 +236,6 @@ gettermcap(HashTable ht, char *name)
     pm = (Param) zhalloc(sizeof(struct param));
     pm->nam = dupstring(name);
     pm->flags = PM_READONLY;
-    pm->sets.cfn = NULL;
-    pm->gets.cfn = strgetfn;
-    pm->sets.ifn = NULL;
-    pm->gets.ifn = intgetfn;
     pm->unsetfn = NULL;
     pm->ct = 0;
     pm->env = NULL;
@@ -251,10 +247,15 @@ gettermcap(HashTable ht, char *name)
     /* logic in the following cascade copied from echotc, above */
 
     if ((num = tgetnum(name)) != -1) {
+	pm->sets.ifn = NULL;
+	pm->gets.ifn = intgetfn;
 	pm->u.val = num;
 	pm->flags |= PM_INTEGER;
 	return (HashNode) pm;
     }
+
+    pm->sets.cfn = NULL;
+    pm->gets.cfn = strgetfn;
     switch (ztgetflag(name)) {
     case -1:
 	break;
@@ -338,10 +339,6 @@ scantermcap(HashTable ht, ScanFunc func, int flags)
 #endif
 
     pm = (Param) zhalloc(sizeof(struct param));
-    pm->sets.cfn = NULL;
-    pm->gets.cfn = strgetfn;
-    pm->sets.ifn = NULL;
-    pm->gets.ifn = intgetfn;
     pm->unsetfn = NULL;
     pm->ct = 0;
     pm->env = NULL;
@@ -350,6 +347,9 @@ scantermcap(HashTable ht, ScanFunc func, int flags)
     u = buf;
 
     pm->flags = PM_READONLY | PM_SCALAR;
+    pm->sets.cfn = NULL;
+    pm->gets.cfn = strgetfn;
+
     for (capcode = (char **)boolcodes; *capcode; capcode++) {
 	if ((num = ztgetflag(*capcode)) != -1) {
 	    pm->u.str = num ? dupstring("yes") : dupstring("no");
@@ -359,6 +359,9 @@ scantermcap(HashTable ht, ScanFunc func, int flags)
     }
 
     pm->flags = PM_READONLY | PM_INTEGER;
+    pm->sets.ifn = NULL;
+    pm->gets.ifn = intgetfn;
+
     for (capcode = (char **)numcodes; *capcode; capcode++) {
 	if ((num = tgetnum(*capcode)) != -1) {
 	    pm->u.val = num;
@@ -368,6 +371,9 @@ scantermcap(HashTable ht, ScanFunc func, int flags)
     }
 
     pm->flags = PM_READONLY | PM_SCALAR;
+    pm->sets.cfn = NULL;
+    pm->gets.cfn = strgetfn;
+
     for (capcode = (char **)strcodes; *capcode; capcode++) {
 	if ((tcstr = (char *)tgetstr(*capcode,&u)) != NULL &&
 	    tcstr != (char *)-1) {
diff --git a/Src/Modules/terminfo.c b/Src/Modules/terminfo.c
index 732495891..744defc8c 100644
--- a/Src/Modules/terminfo.c
+++ b/Src/Modules/terminfo.c
@@ -175,10 +175,6 @@ getterminfo(HashTable ht, char *name)
     pm = (Param) zhalloc(sizeof(struct param));
     pm->nam = dupstring(name);
     pm->flags = PM_READONLY;
-    pm->sets.cfn = NULL;
-    pm->gets.cfn = strgetfn;
-    pm->sets.ifn = NULL;
-    pm->gets.ifn = intgetfn;
     pm->unsetfn = NULL;
     pm->ct = 0;
     pm->env = NULL;
@@ -189,21 +185,29 @@ getterminfo(HashTable ht, char *name)
     if (((num = tigetnum(name)) != -1) && (num != -2)) {
 	pm->u.val = num;
 	pm->flags |= PM_INTEGER;
+	pm->sets.ifn = NULL;
+	pm->gets.ifn = intgetfn;
     }
     else if ((num = tigetflag(name)) != -1) {
 	pm->u.str = num ? dupstring("yes") : dupstring("no");
 	pm->flags |= PM_SCALAR;
+        pm->sets.cfn = NULL;
+        pm->gets.cfn = strgetfn;
     }
     else if ((tistr = (char *)tigetstr(name)) != NULL && tistr != (char *)-1)
     {
 	pm->u.str = dupstring(tistr);
 	pm->flags |= PM_SCALAR;
+        pm->sets.cfn = NULL;
+        pm->gets.cfn = strgetfn;
     }
     else
     {
 	/* zwarn("no such capability: %s", name, 0); */
 	pm->u.str = dupstring("");
 	pm->flags |= PM_UNSET;
+        pm->sets.cfn = NULL;
+        pm->gets.cfn = strgetfn;
     }
     return (HashNode) pm;
 }
@@ -287,10 +291,6 @@ scanterminfo(HashTable ht, ScanFunc func, int flags)
 #endif
 
     pm = (Param) zhalloc(sizeof(struct param));
-    pm->sets.cfn = NULL;
-    pm->gets.cfn = strgetfn;
-    pm->sets.ifn = NULL;
-    pm->gets.ifn = intgetfn;
     pm->unsetfn = NULL;
     pm->ct = 0;
     pm->env = NULL;
@@ -298,6 +298,9 @@ scanterminfo(HashTable ht, ScanFunc func, int flags)
     pm->old = NULL;
     
     pm->flags = PM_READONLY | PM_SCALAR;
+    pm->sets.cfn = NULL;
+    pm->gets.cfn = strgetfn;
+
     for (capname = (char **)boolnames; *capname; capname++) {
 	if ((num = tigetflag(*capname)) != -1) {
 	    pm->u.str = num ? dupstring("yes") : dupstring("no");
@@ -305,8 +308,11 @@ scanterminfo(HashTable ht, ScanFunc func, int flags)
 	    func((HashNode) pm, flags);
 	}
     }
-    
+
     pm->flags = PM_READONLY | PM_INTEGER;
+    pm->sets.ifn = NULL;
+    pm->gets.ifn = intgetfn;
+
     for (capname = (char **)numnames; *capname; capname++) {
 	if (((num = tigetnum(*capname)) != -1) && (num != -2)) {
 	    pm->u.val = num;
@@ -314,8 +320,11 @@ scanterminfo(HashTable ht, ScanFunc func, int flags)
 	    func((HashNode) pm, flags);
 	}
     }
-    
+
     pm->flags = PM_READONLY | PM_SCALAR;
+    pm->sets.cfn = NULL;
+    pm->gets.cfn = strgetfn;
+
     for (capname = (char **)strnames; *capname; capname++) {
 	if ((tistr = (char *)tigetstr(*capname)) != NULL &&
 	    tistr != (char *)-1) {