mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-17 22:31:12 +01:00
Make termcap and terminfo modules always loadable.
This commit is contained in:
parent
b75b87c8d9
commit
5d0231e105
5 changed files with 61 additions and 23 deletions
|
@ -1,3 +1,10 @@
|
|||
2001-04-09 Bart Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 13922: Src/Modules/termcap.c, Src/Modules/termcap.mdd,
|
||||
Src/Modules/terminfo.c, Src/Modules/terminfo.mdd: Loading these
|
||||
modules should work even if the corresponding library is not
|
||||
available; in that case echotc or echoti uses bin_notavail.
|
||||
|
||||
2001-04-09 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* unposted: Config/version.mk: 4.0.1-pre-3.
|
||||
|
|
|
@ -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),
|
||||
};
|
||||
|
|
|
@ -6,11 +6,16 @@ link='if test "x$ac_cv_func_tgetent" = xyes; then
|
|||
else
|
||||
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"
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,11 +6,16 @@ link='if test "x$ac_cv_func_tigetstr" = xyes; then
|
|||
else
|
||||
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"
|
||||
|
|
Loading…
Reference in a new issue