summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Modules/termcap.c8
-rw-r--r--Src/Modules/termcap.mdd7
-rw-r--r--Src/Modules/terminfo.c55
-rw-r--r--Src/Modules/terminfo.mdd7
4 files changed, 54 insertions, 23 deletions
diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c
index 9c72bf27f..dad47aa17 100644
--- a/Src/Modules/termcap.c
+++ b/Src/Modules/termcap.c
@@ -32,6 +32,8 @@
 
 /* echotc: output a termcap */
 
+#ifdef HAVE_TGETENT
+
 /**/
 static int
 bin_echotc(char *name, char **argv, char *ops, int func)
@@ -100,6 +102,12 @@ bin_echotc(char *name, char **argv, char *ops, int func)
     return 0;
 }
 
+#else /* ! HAVE_TGETENT */
+
+#define bin_echotc bin_notavail
+
+#endif /* HAVE_TGETENT */
+
 static struct builtin bintab[] = {
     BUILTIN("echotc", 0, bin_echotc, 1, -1, 0, NULL, NULL),
 };
diff --git a/Src/Modules/termcap.mdd b/Src/Modules/termcap.mdd
index 89f939ff8..9a6ddd08e 100644
--- a/Src/Modules/termcap.mdd
+++ b/Src/Modules/termcap.mdd
@@ -7,10 +7,15 @@ link='if test "x$ac_cv_func_tgetent" = xyes; then
 	      echo static
 	  fi
       else
+          echo either;
+      fi
+'
+load='if test "x$ac_cv_func_tgetent" = xyes; then
+          echo yes;
+      else
           echo no;
       fi
 '
-load=yes
 
 autobins="echotc"
 
diff --git a/Src/Modules/terminfo.c b/Src/Modules/terminfo.c
index 7eb47bdb3..0cac6e530 100644
--- a/Src/Modules/terminfo.c
+++ b/Src/Modules/terminfo.c
@@ -35,13 +35,15 @@ static Param terminfo_pm;
 
 /* echoti: output a terminfo capability */
 
+#ifdef HAVE_TIGETSTR
+
 /**/
 static int
 bin_echoti(char *name, char **argv, char *ops, int func)
 {
     char *s, *t;
     int num;
-    
+
     s = *argv++;
     /* This depends on the termcap stuff in init.c */
     if (termflags & TERM_BAD)
@@ -53,7 +55,7 @@ bin_echoti(char *name, char **argv, char *ops, int func)
 	printf("%d\n", num);
 	return 0;
     }
-    
+
     switch (tigetflag(s)) {
     case -1:
 	break;
@@ -64,7 +66,7 @@ bin_echoti(char *name, char **argv, char *ops, int func)
 	puts("yes");
 	return 0;
     }
-    
+
 /* get a string-type capability */
     t = (char *)tigetstr(s);
     if (!t || t == (char *)-1 || !*t) {
@@ -72,11 +74,17 @@ bin_echoti(char *name, char **argv, char *ops, int func)
 	zwarnnam(name, "no such terminfo capability: %s", s, 0);
 	return 1;
     }
-    
+
     tputs(t, 1, putchar);
     return 0;
 }
 
+#else
+
+#define bin_echoti bin_notavail
+
+#endif
+
 static struct builtin bintab[] = {
     BUILTIN("echoti", 0, bin_echoti, 1, -1, 0, NULL, NULL),
 };
@@ -85,6 +93,8 @@ static struct builtin bintab[] = {
 
 static int incleanup;
 
+#ifdef HAVE_TIGETSTR
+
 /* Empty dummy function for special hash parameters. */
 
 /**/
@@ -101,19 +111,19 @@ createtihash()
 {
     Param pm;
     HashTable ht;
-    
+
     unsetparam(terminfo_nam);
-    
+
     if (!(pm = createparam(terminfo_nam, PM_SPECIAL|PM_HIDE|PM_HIDEVAL|
 			   PM_REMOVABLE|PM_HASHED)))
 	return NULL;
-    
+
     pm->level = pm->old ? locallevel : 0;
     pm->gets.hfn = hashgetfn;
     pm->sets.hfn = hashsetfn;
     pm->unsetfn = stdunsetfn;
     pm->u.hash = ht = newhashtable(7, terminfo_nam, NULL);
-    
+
     ht->hash        = hasher;
     ht->emptytable  = (TableFunc) shempty;
     ht->filltable   = NULL;
@@ -142,9 +152,9 @@ getterminfo(HashTable ht, char *name)
 	return NULL;
     if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
 	return NULL;
-    
+
     unmetafy(name, &len);
-    
+
     pm = (Param) zhalloc(sizeof(struct param));
     pm->nam = dupstring(name);
     pm->flags = PM_READONLY;
@@ -156,7 +166,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;
@@ -172,12 +182,11 @@ getterminfo(HashTable ht, char *name)
     }
     else
     {
-	zwarn("no such capability: %s", name, 0);
+	/* zwarn("no such capability: %s", name, 0); */
 	pm->u.str = dupstring("");
 	pm->flags |= PM_UNSET;
     }
     return (HashNode) pm;
-    
 }
 
 /**/
@@ -186,12 +195,14 @@ scanterminfo(HashTable ht, ScanFunc func, int flags)
 {
 }
 
+#endif /* HAVE_TIGETSTR */
+
 /**/
 int
 setup_(Module m)
 {
     incleanup = 0;
-    
+
     return 0;
 }
 
@@ -199,9 +210,13 @@ setup_(Module m)
 int
 boot_(Module m)
 {
+#ifdef HAVE_TIGETSTR
     setupterm((char *)0, 1, (int *)0);
 
-    return !createtihash() || !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
+    if (!createtihash())
+    	return 1;
+#endif
+    return  !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
 }
 
 /**/
@@ -209,14 +224,16 @@ int
 cleanup_(Module m)
 {
     Param pm;
-    
+
     incleanup = 1;
-    
+
+#ifdef HAVE_TIGETSTR
     if ((pm = (Param) paramtab->getnode(paramtab, terminfo_nam)) &&
 	pm == terminfo_pm) {
 	pm->flags &= ~PM_READONLY;
 	unsetparam_pm(pm, 0, 1);
     }
+#endif
     deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
     return 0;
 }
@@ -227,7 +244,3 @@ finish_(Module m)
 {
     return 0;
 }
-
-
-
-
diff --git a/Src/Modules/terminfo.mdd b/Src/Modules/terminfo.mdd
index dd01bed3a..580aa2893 100644
--- a/Src/Modules/terminfo.mdd
+++ b/Src/Modules/terminfo.mdd
@@ -7,10 +7,15 @@ link='if test "x$ac_cv_func_tigetstr" = xyes; then
 	      echo static
 	  fi
       else
+          echo either;
+      fi
+'
+load='if test "x$ac_cv_func_tigetstr" = xyes; then
+          echo yes;
+      else
           echo no;
       fi
 '
-load=yes
 
 autobins="echoti"
 autoparams="terminfo"