about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2000-12-05 00:28:40 +0000
committerClint Adams <clint@users.sourceforge.net>2000-12-05 00:28:40 +0000
commit5d7a9e949b18880ca49e66af23670770957a770d (patch)
tree64e8f234aabdfab6103b274903cc17b73f36a19a /Src
parentcfe1038ff13f5a6e11dab1fe109edafa274093ac (diff)
downloadzsh-5d7a9e949b18880ca49e66af23670770957a770d.tar.gz
zsh-5d7a9e949b18880ca49e66af23670770957a770d.tar.xz
zsh-5d7a9e949b18880ca49e66af23670770957a770d.zip
13227: terminfo module fixes
Diffstat (limited to 'Src')
-rw-r--r--Src/Modules/terminfo.c103
-rw-r--r--Src/Modules/terminfo.mdd2
2 files changed, 56 insertions, 49 deletions
diff --git a/Src/Modules/terminfo.c b/Src/Modules/terminfo.c
index 3ad8a8a27..4fe1b3cec 100644
--- a/Src/Modules/terminfo.c
+++ b/Src/Modules/terminfo.c
@@ -39,46 +39,47 @@ static Param terminfo_pm;
 int
 bin_echoti(char *name, char **argv, char *ops, int func)
 {
-    char *s, buf[2048], *t, *u;
-    int num, argct;
+    char *s, *t;
+    int num;
     
     s = *argv++;
+    /* This depends on the termcap stuff in init.c */
     if (termflags & TERM_BAD)
 	return 1;
     if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
 	return 1;
     /* if the specified capability has a numeric value, display it */
     if (((num = tigetnum(s)) != -1) && (num != -2)) {
-    printf("%d\n", num);
-    return 0;
-}
-
-switch (tigetflag(s)) {
- case -1:
-     break;
- case 0:
-     puts("no");
-     return 0;
- default:
-     puts("yes");
-     return 0;
-}
-
+	printf("%d\n", num);
+	return 0;
+    }
+    
+    switch (tigetflag(s)) {
+    case -1:
+	break;
+    case 0:
+	puts("no");
+	return 0;
+    default:
+	puts("yes");
+	return 0;
+    }
+    
 /* get a string-type capability */
-t = tigetstr(s);
-if (!t || !*t) {
-    /* capability doesn't exist, or (if boolean) is off */
-    zwarnnam(name, "no such terminfo capability: %s", s, 0);
-    return 1;
-}
-
-printf("%s", t);
-return 0;
+    t = (char *)tigetstr(s);
+    if (!t || !*t) {
+	/* capability doesn't exist, or (if boolean) is off */
+	zwarnnam(name, "no such terminfo capability: %s", s, 0);
+	return 1;
+    }
+    
+    tputs(t, 1, putchar);
+    return 0;
 }
 
 static struct builtin bintab[] = {
-BUILTIN("echoti", 0, bin_echoti, 1, -1, 0, NULL, NULL),
-    };
+    BUILTIN("echoti", 0, bin_echoti, 1, -1, 0, NULL, NULL),
+};
 
 /* This says if we are cleaning up when the module is unloaded. */
 
@@ -100,7 +101,7 @@ createtihash()
 {
     Param pm;
     HashTable ht;
-
+    
     unsetparam(terminfo_nam);
     
     if (!(pm = createparam(terminfo_nam, PM_SPECIAL|PM_HIDE|PM_HIDEVAL|
@@ -136,13 +137,14 @@ getterminfo(HashTable ht, char *name)
     char *tistr;
     Param pm = NULL;
 
+    /* This depends on the termcap stuff in init.c */
     if (termflags & TERM_BAD)
-	return 1;
+	return NULL;
     if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
-	return 1;
-
+	return NULL;
+    
     unmetafy(name, &len);
-
+    
     pm = (Param) zhalloc(sizeof(struct param));
     pm->nam = dupstring(name);
     pm->flags = PM_READONLY;
@@ -154,7 +156,7 @@ getterminfo(HashTable ht, char *name)
     pm->ename = NULL;
     pm->old = NULL;
     pm->level = 0;
-
+    
     if (((num = tigetnum(name)) != -1) && (num != -2)) {
 	pm->u.val = num;
 	pm->flags |= PM_INTEGER;
@@ -163,26 +165,25 @@ getterminfo(HashTable ht, char *name)
 	pm->u.str = num ? dupstring("yes") : dupstring("no");
 	pm->flags |= PM_SCALAR;
     }
-    else if ((tistr = tigetstr(name)) != NULL)
+    else if ((tistr = (char *)tigetstr(name)) != NULL)
     {
 	pm->u.str = dupstring(tistr);
 	pm->flags |= PM_SCALAR;
     }
     else
     {
-    zwarn("no such capability: %s", name, 0);
-    pm->u.str = dupstring("");
-    pm->flags |= PM_UNSET;
+	zwarn("no such capability: %s", name, 0);
+	pm->u.str = dupstring("");
+	pm->flags |= PM_UNSET;
     }
     return (HashNode) pm;
-
+    
 }
 
 /**/
 static void
 scanterminfo(HashTable ht, ScanFunc func, int flags)
 {
-return 0;	    
 }
 
 /**/
@@ -190,7 +191,7 @@ int
 setup_(Module m)
 {
     incleanup = 0;
-
+    
     return 0;
 }
 
@@ -198,6 +199,8 @@ setup_(Module m)
 int
 boot_(Module m)
 {
+    setupterm((char *)0, 1, (int *)0);
+
     return !createtihash() || !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
 }
 
@@ -206,14 +209,14 @@ int
 cleanup_(Module m)
 {
     Param pm;
-
+    
     incleanup = 1;
-
-	if ((pm = (Param) paramtab->getnode(paramtab, terminfo_nam)) &&
-	    pm == terminfo_pm) {
-	    pm->flags &= ~PM_READONLY;
-	    unsetparam_pm(pm, 0, 1);
-	}
+    
+    if ((pm = (Param) paramtab->getnode(paramtab, terminfo_nam)) &&
+	pm == terminfo_pm) {
+	pm->flags &= ~PM_READONLY;
+	unsetparam_pm(pm, 0, 1);
+    }
     deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
     return 0;
 }
@@ -224,3 +227,7 @@ finish_(Module m)
 {
     return 0;
 }
+
+
+
+
diff --git a/Src/Modules/terminfo.mdd b/Src/Modules/terminfo.mdd
index cb628dd30..742c35745 100644
--- a/Src/Modules/terminfo.mdd
+++ b/Src/Modules/terminfo.mdd
@@ -1,5 +1,5 @@
 name=zsh/terminfo
-link=either
+link=`if test "x$ac_cv_have_tigetstr" = xyes; then echo either; else echo no; fi`
 load=yes
 
 autobins="echoti"