From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16663 invoked from network); 5 Dec 2000 00:23:45 -0000 Received: from sunsite.dk (HELO sunsite.auc.dk) (130.225.51.30) by ns1.primenet.com.au with SMTP; 5 Dec 2000 00:23:45 -0000 Received: (qmail 29184 invoked by alias); 5 Dec 2000 00:23:36 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13227 Received: (qmail 29177 invoked from network); 5 Dec 2000 00:23:35 -0000 Date: Mon, 4 Dec 2000 19:23:08 -0500 From: Clint Adams To: Bart Schaefer Cc: Zsh hackers list Subject: Re: PATCH: termcap/terminfo support in modules Message-ID: <20001204192308.A4194@dman.com> References: <0G5100AE1ZGG5J@la-la.cambridgesiliconradio.com> <1001204172718.ZM19960@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <1001204172718.ZM19960@candle.brasslantern.com>; from schaefer@candle.brasslantern.com on Mon, Dec 04, 2000 at 05:27:18PM +0000 > It's not that they're not defined, they're just not in a library that > configure is testing for. Or rather, configure is not testing for those > functions in particular, even though it does test for -lcurses. Right. So we won't build the module unless we find tiget* in -ltermcap or whatever has tgetent(). > Other random things I noticed: This should address all but the potential namespace conflict. Index: configure.in =================================================================== RCS file: /cvsroot/zsh/zsh/configure.in,v retrieving revision 1.36 diff -u -r1.36 configure.in --- configure.in 2000/12/04 19:21:06 1.36 +++ configure.in 2000/12/05 00:10:54 @@ -848,7 +848,8 @@ signgam \ putenv getenv \ brk sbrk \ - pathconf sysconf) + pathconf sysconf \ + tigetflag tigetnum tigetstr) AC_FUNC_STRCOLL AC_FUNC_MMAP Index: Src/Modules/terminfo.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v retrieving revision 1.1 diff -u -r1.1 terminfo.c --- Src/Modules/terminfo.c 2000/12/03 20:53:25 1.1 +++ Src/Modules/terminfo.c 2000/12/05 00:10:56 @@ -39,46 +39,47 @@ 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 @@ { Param pm; HashTable ht; - + unsetparam(terminfo_nam); if (!(pm = createparam(terminfo_nam, PM_SPECIAL|PM_HIDE|PM_HIDEVAL| @@ -136,13 +137,14 @@ 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 @@ 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 @@ 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 @@ setup_(Module m) { incleanup = 0; - + return 0; } @@ -198,6 +199,8 @@ int boot_(Module m) { + setupterm((char *)0, 1, (int *)0); + return !createtihash() || !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab)); } @@ -206,14 +209,14 @@ 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 @@ { return 0; } + + + + Index: Src/Modules/terminfo.mdd =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.mdd,v retrieving revision 1.1 diff -u -r1.1 terminfo.mdd --- Src/Modules/terminfo.mdd 2000/12/03 20:53:25 1.1 +++ Src/Modules/terminfo.mdd 2000/12/05 00:10:56 @@ -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"