1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-04 10:41:11 +02:00

13227: terminfo module fixes

This commit is contained in:
Clint Adams 2000-12-05 00:28:40 +00:00
parent cfe1038ff1
commit 5d7a9e949b
4 changed files with 67 additions and 50 deletions

View file

@ -1,3 +1,12 @@
2000-12-04 Clint Adams <schizo@debian.org>
* 13227: configure.in, Src/Modules/terminfo.c,
Src/Modules/terminfo.mdd: do not build terminfo
module if tigetstr() is not found in the same library
as tgetent(), indentation fix, use tputs() in echoti
builtin for outputting string capabilities, use
setupterm() for module boot.
2000-12-04 Peter Stephenson <pws@csr.com>
* 13226: configure.in, Config/defs.mk, Config/installfns.sh,

View file

@ -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);
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 = (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;
}
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;
}
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. */
@ -136,10 +137,11 @@ 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);
@ -163,16 +165,16 @@ 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;
@ -182,7 +184,6 @@ getterminfo(HashTable ht, char *name)
static void
scanterminfo(HashTable ht, ScanFunc func, int flags)
{
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));
}
@ -209,11 +212,11 @@ cleanup_(Module m)
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;
}

View file

@ -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"

View file

@ -848,7 +848,8 @@ AC_CHECK_FUNCS(strftime difftime gettimeofday \
signgam \
putenv getenv \
brk sbrk \
pathconf sysconf)
pathconf sysconf \
tigetflag tigetnum tigetstr)
AC_FUNC_STRCOLL
AC_FUNC_MMAP