about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2001-05-30 15:39:31 +0000
committerBart Schaefer <barts@users.sourceforge.net>2001-05-30 15:39:31 +0000
commit14be3dd5e46eaf1d3b8488730d2fb5cf704594bc (patch)
treeb2ad5d81698bb617ff7062924f51a827b4e55634
parent13476e2a866281214bb27d97547ec5c94e37b12c (diff)
downloadzsh-14be3dd5e46eaf1d3b8488730d2fb5cf704594bc.tar.gz
zsh-14be3dd5e46eaf1d3b8488730d2fb5cf704594bc.tar.xz
zsh-14be3dd5e46eaf1d3b8488730d2fb5cf704594bc.zip
Improve gettermcap().
-rw-r--r--ChangeLog8
-rw-r--r--Src/Modules/termcap.c35
2 files changed, 34 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 19262fedc..ab2bcc623 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-05-30  Bart Schaefer  <schaefer@zsh.org>
+
+	* 14516: Use the same ncurses compilation test in gettermcap() as
+	was already used in echotc().  This needs more work, hence the
+	delay in getting it committed.
+
 2001-05-30  Oliver Kiddle  <opk@zsh.org>
 
 	* 14567: Completion/Unix/Command/_pine,
@@ -25,7 +31,7 @@
 
 2001-05-29  Clint Adams  <clint@zsh.org>
 
-	* 145??: Src/Zle/zle_hist.c: fix thinko
+	* 14553: Src/Zle/zle_hist.c: fix thinko
 
 	* 14552: Src/Zle/zle_hist.c: repeat last vi history search
 	if search string is empty.
diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c
index ddba69a6d..032335fb3 100644
--- a/Src/Modules/termcap.c
+++ b/Src/Modules/termcap.c
@@ -109,7 +109,7 @@ bin_echotc(char *name, char **argv, char *ops, int func)
     /* get a string-type capability */
     u = buf;
     t = tgetstr(s, &u);
-    if (!t || !*t) {
+    if (t == (char *)-1 || !t || !*t) {
 	/* capability doesn't exist, or (if boolean) is off */
 	zwarnnam(name, "no such capability: %s", s, 0);
 	return 1;
@@ -225,15 +225,34 @@ gettermcap(HashTable ht, char *name)
     pm->level = 0;
     u = buf;
 
+    /* logic in the following cascade copied from echotc, above */
+
     if ((num = tgetnum(name)) != -1) {
 	pm->u.val = num;
 	pm->flags |= PM_INTEGER;
+	return (HashNode) pm;
     }
-    else if ((num = tgetflag(name)) != -1) {
-	pm->u.str = num ? dupstring("yes") : dupstring("no");
+#if !defined(NCURSES_VERSION) || !defined(COLOR_PAIR)
+    if ((num = tgetflag(name)) > 0) {
+	pm->u.str = dupstring("yes");
 	pm->flags |= PM_SCALAR;
+	return (HashNode) pm;
     }
-    else if ((tcstr = (char *)tgetstr(name,&u)) != NULL && tcstr != (char *)-1)
+#else /* NCURSES_VERSION && COLOR_PAIR */
+    switch (tgetflag(name)) {
+    case -1:
+	break;
+    case 0:
+	pm->u.str = dupstring("no");
+	pm->flags |= PM_SCALAR;
+	return (HashNode) pm;
+    default:
+	pm->u.str = dupstring("yes");
+	pm->flags |= PM_SCALAR;
+	return (HashNode) pm;
+    }
+#endif /* NCURSES_VERSION && COLOR_PAIR */
+    if ((tcstr = tgetstr(name, &u)) != NULL && tcstr != (char *)-1)
     {
 	pm->u.str = dupstring(tcstr);
 	pm->flags |= PM_SCALAR;
@@ -262,7 +281,7 @@ scantermcap(HashTable ht, ScanFunc func, int flags)
 	"mi", "ms", "nx", "xb", "NP", "ND", "NR", "os", "5i", "YD", "YE",
 	"es", "hz", "ul", "xo", NULL};
 #endif
-    
+
 #ifndef HAVE_NUMCODES
     static char *numcodes[] = {
 	"co", "it", "lh", "lw", "li", "lm", "sg", "ma", "Co", "pa", "MW",
@@ -322,7 +341,7 @@ scantermcap(HashTable ht, ScanFunc func, int flags)
     pm->ename = NULL;
     pm->old = NULL;
     u = buf;
-    
+
     pm->flags = PM_READONLY | PM_SCALAR;
     for (capcode = (char **)boolcodes; *capcode; capcode++) {
 	if ((num = tgetflag(*capcode)) != -1) {
@@ -331,7 +350,7 @@ scantermcap(HashTable ht, ScanFunc func, int flags)
 	    func((HashNode) pm, flags);
 	}
     }
-    
+
     pm->flags = PM_READONLY | PM_INTEGER;
     for (capcode = (char **)numcodes; *capcode; capcode++) {
 	if ((num = tgetnum(*capcode)) != -1) {
@@ -340,7 +359,7 @@ scantermcap(HashTable ht, ScanFunc func, int flags)
 	    func((HashNode) pm, flags);
 	}
     }
-    
+
     pm->flags = PM_READONLY | PM_SCALAR;
     for (capcode = (char **)strcodes; *capcode; capcode++) {
 	if ((tcstr = (char *)tgetstr(*capcode,&u)) != NULL &&