Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: use curses library capability inventory and hope it's terminfo



>        char *boolnames, *boolcodes, *boolfnames
> 
>        char *numnames, *numcodes, *numfnames
> 
>        char *strnames, *strcodes, *strfnames
> 
>        These null-terminated arrays  contain  the  capnames,  the
>        termcap  codes, and the full C names, for each of the ter-
>        minfo variables.
> 
> Could we configure-check for the availability of these variables and use
> yours as fallbacks in the event that the above are not found?

Note that it says "termcap" codes.  The great thing is that on Solaris,
it will actually contain terminfo capability names (which is what we
want), but under ncurses, it will contain termcap capability names.

So the following patch (which I'll commit anyway) will break on
ncurses.  The best idea I can come up with to solve this is to
have configure check the length of each capability string,
then assume termcap if they're all 2, otherwise assume terminfo.
I'll probably try that tomorrow if no one has other suggestions.

Index: acconfig.h
===================================================================
RCS file: /cvsroot/zsh/zsh/acconfig.h,v
retrieving revision 1.4
diff -u -r1.4 acconfig.h
--- acconfig.h	2000/07/04 08:44:03	1.4
+++ acconfig.h	2001/04/12 02:37:12
@@ -299,3 +299,12 @@
 
 /* Define to 1 if h_errno is not defined by the system */
 #undef USE_LOCAL_H_ERRNO
+
+/* Define if you have the terminfo boolcodes symbol.  */
+#undef HAVE_BOOLCODES
+
+/* Define if you have the terminfo numcodes symbol.  */
+#undef HAVE_NUMCODES
+
+/* Define if you have the terminfo strcodes symbol.  */
+#undef HAVE_STRCODES
Index: configure.in
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.in,v
retrieving revision 1.41
diff -u -r1.41 configure.in
--- configure.in	2001/03/07 11:40:48	1.41
+++ configure.in	2001/04/12 02:37:12
@@ -439,7 +439,7 @@
 		 limits.h fcntl.h libc.h sys/utsname.h sys/resource.h \
 		 locale.h errno.h stdlib.h unistd.h sys/capability.h \
 		 utmp.h utmpx.h sys/types.h pwd.h grp.h poll.h sys/mman.h \
-		 linux/tasks.h netinet/in_systm.h)
+		 linux/tasks.h netinet/in_systm.h curses.h term.h)
 if test $dynamic = yes; then
   AC_CHECK_HEADERS(dlfcn.h)
   AC_CHECK_HEADERS(dl.h)
@@ -515,6 +515,21 @@
 esac
 
 AC_SEARCH_LIBS(tgetent, [$termcap_curses_order])
+AC_MSG_CHECKING(if boolcodes is available)
+AC_TRY_COMPILE([#include <curses.h>
+#include <term.h>], [char **test = boolcodes;],
+AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes, boolcodes=no)
+AC_MSG_RESULT($boolcodes)
+AC_MSG_CHECKING(if numcodes is available)
+AC_TRY_COMPILE([#include <curses.h>
+#include <term.h>], [char **test = numcodes;],
+AC_DEFINE(HAVE_NUMCODES) numcodes=yes, numcodes=no)
+AC_MSG_RESULT($numcodes)
+AC_MSG_CHECKING(if strcodes is available)
+AC_TRY_COMPILE([#include <curses.h>
+#include <term.h>], [char **test = strcodes;],
+AC_DEFINE(HAVE_STRCODES) strcodes=yes, strcodes=no)
+AC_MSG_RESULT($strcodes)
 
 dnl Some systems (Solaris 2.x, Linux Redhat 5.x) require
 dnl libnsl (Network Services Library) to find yp_all
Index: Src/Modules/terminfo.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v
retrieving revision 1.10
diff -u -r1.10 terminfo.c
--- Src/Modules/terminfo.c	2001/04/12 00:32:29	1.10
+++ Src/Modules/terminfo.c	2001/04/12 02:37:12
@@ -29,6 +29,12 @@
 
 #include "terminfo.mdh"
 #include "terminfo.pro"
+#ifdef HAVE_CURSES_H
+# include <curses.h>
+#endif
+#ifdef HAVE_TERM_H
+# include <term.h>
+#endif
 
 static char terminfo_nam[] = "terminfo";
 
@@ -202,20 +208,25 @@
     int num;
     char **capname, *tistr;
 
-    static char *bools[] = {
+#ifndef HAVE_BOOLCODES
+    static char *boolcodes[] = {
 	"bw", "am", "bce", "ccc", "xhp", "xhpa", "cpix", "crxm", "xt", "xenl",
 	"eo", "gn", "hc", "chts", "km", "daisy", "hs", "hls", "in", "lpix",
 	"da", "db", "mir", "msgr", "nxon", "xsb", "npc", "ndscr", "nrrmc",
 	"os", "mc5i", "xvpa", "sam", "eslok", "hz", "ul", "xon", NULL};
+#endif
     
-    static char *numerics[] = {
+#ifndef HAVE_NUMCODES
+    static char *numcodes[] = {
 	"cols", "it", "lh", "lw", "lines", "lm", "xmc", "ma", "colors",
 	"pairs", "wnum", "ncv", "nlab", "pb", "vt", "wsl", "bitwin",
 	"bitype", "bufsz", "btns", "spinh", "spinv", "maddr", "mjump",
 	"mcs", "mls", "npins", "orc", "orhi", "orl", "orvi", "cps", "widcs",
 	NULL};
+#endif
 
-    static char *strings[] = {
+#ifndef HAVE_STRCODES
+    static char *strcodes[] = {
 	"acsc", "cbt", "bel", "cr", "cpi", "lpi", "chr", "cvr", "csr", "rmp",
 	"tbc", "mgc", "clear", "el1", "el", "ed", "hpa", "cmdch", "cwin",
 	"cup", "cud1", "home", "civis", "cub1", "mrcup", "cnorm", "cuf1",
@@ -265,6 +276,7 @@
 	"setab", "setaf", "setcolor", "smglr", "slines", "smgtb",
 	"ehhlm", "elhlm", "elohlm", "erhlm", "ethlm", "evhlm", "sgr1",
 	"slength", NULL};
+#endif
 
     pm = (Param) zhalloc(sizeof(struct param));
     pm->sets.cfn = NULL;
@@ -276,7 +288,7 @@
     pm->old = NULL;
     
     pm->flags = PM_READONLY | PM_SCALAR;
-    for (capname = bools; *capname; capname++) {
+    for (capname = (char **)boolcodes; *capname; capname++) {
 	if ((num = tigetflag(*capname)) != -1) {
 	    pm->u.str = num ? dupstring("yes") : dupstring("no");
 	    pm->nam = dupstring(*capname);
@@ -285,7 +297,7 @@
     }
     
     pm->flags = PM_READONLY | PM_INTEGER;
-    for (capname = numerics; *capname; capname++) {
+    for (capname = (char **)numcodes; *capname; capname++) {
 	if (((num = tigetnum(*capname)) != -1) && (num != -2)) {
 	    pm->u.val = num;
 	    pm->nam = dupstring(*capname);
@@ -294,7 +306,7 @@
     }
     
     pm->flags = PM_READONLY | PM_SCALAR;
-    for (capname = strings; *capname; capname++) {
+    for (capname = (char **)strcodes; *capname; capname++) {
 	if ((tistr = (char *)tigetstr(*capname)) != NULL &&
 	    tistr != (char *)-1) {
 	    pm->u.str = dupstring(tistr);



Messages sorted by: Reverse Date, Date, Thread, Author