1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-06-06 23:36:03 +02:00

17481 (Karl Tomlinson): get/set for terminfo and termcap parameters

This commit is contained in:
Peter Stephenson 2002-10-07 11:48:06 +00:00
parent 5445efbb91
commit 3ad5e3e7fe
3 changed files with 39 additions and 18 deletions

View File

@ -1,3 +1,9 @@
2002-10-07 Peter Stephenson <pws@csr.com>
* 17482 (Karl Tomlinson): Src/Modules/termcap.c,
Src/Modules/terminfo.c: resolve confusion over use of get/set
functions for special parameters. Copied from 4.0.
2002-10-06 Bart Schaefer <schaefer@zsh.org> 2002-10-06 Bart Schaefer <schaefer@zsh.org>
* 17760: Src/lex.c Src/parse.c: Fix case-pattern parsing bug in sh * 17760: Src/lex.c Src/parse.c: Fix case-pattern parsing bug in sh

View File

@ -236,10 +236,6 @@ gettermcap(HashTable ht, char *name)
pm = (Param) zhalloc(sizeof(struct param)); pm = (Param) zhalloc(sizeof(struct param));
pm->nam = dupstring(name); pm->nam = dupstring(name);
pm->flags = PM_READONLY; pm->flags = PM_READONLY;
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
pm->sets.ifn = NULL;
pm->gets.ifn = intgetfn;
pm->unsetfn = NULL; pm->unsetfn = NULL;
pm->ct = 0; pm->ct = 0;
pm->env = NULL; pm->env = NULL;
@ -251,10 +247,15 @@ gettermcap(HashTable ht, char *name)
/* logic in the following cascade copied from echotc, above */ /* logic in the following cascade copied from echotc, above */
if ((num = tgetnum(name)) != -1) { if ((num = tgetnum(name)) != -1) {
pm->sets.ifn = NULL;
pm->gets.ifn = intgetfn;
pm->u.val = num; pm->u.val = num;
pm->flags |= PM_INTEGER; pm->flags |= PM_INTEGER;
return (HashNode) pm; return (HashNode) pm;
} }
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
switch (ztgetflag(name)) { switch (ztgetflag(name)) {
case -1: case -1:
break; break;
@ -338,10 +339,6 @@ scantermcap(HashTable ht, ScanFunc func, int flags)
#endif #endif
pm = (Param) zhalloc(sizeof(struct param)); pm = (Param) zhalloc(sizeof(struct param));
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
pm->sets.ifn = NULL;
pm->gets.ifn = intgetfn;
pm->unsetfn = NULL; pm->unsetfn = NULL;
pm->ct = 0; pm->ct = 0;
pm->env = NULL; pm->env = NULL;
@ -350,6 +347,9 @@ scantermcap(HashTable ht, ScanFunc func, int flags)
u = buf; u = buf;
pm->flags = PM_READONLY | PM_SCALAR; pm->flags = PM_READONLY | PM_SCALAR;
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
for (capcode = (char **)boolcodes; *capcode; capcode++) { for (capcode = (char **)boolcodes; *capcode; capcode++) {
if ((num = ztgetflag(*capcode)) != -1) { if ((num = ztgetflag(*capcode)) != -1) {
pm->u.str = num ? dupstring("yes") : dupstring("no"); pm->u.str = num ? dupstring("yes") : dupstring("no");
@ -359,6 +359,9 @@ scantermcap(HashTable ht, ScanFunc func, int flags)
} }
pm->flags = PM_READONLY | PM_INTEGER; pm->flags = PM_READONLY | PM_INTEGER;
pm->sets.ifn = NULL;
pm->gets.ifn = intgetfn;
for (capcode = (char **)numcodes; *capcode; capcode++) { for (capcode = (char **)numcodes; *capcode; capcode++) {
if ((num = tgetnum(*capcode)) != -1) { if ((num = tgetnum(*capcode)) != -1) {
pm->u.val = num; pm->u.val = num;
@ -368,6 +371,9 @@ scantermcap(HashTable ht, ScanFunc func, int flags)
} }
pm->flags = PM_READONLY | PM_SCALAR; pm->flags = PM_READONLY | PM_SCALAR;
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
for (capcode = (char **)strcodes; *capcode; capcode++) { for (capcode = (char **)strcodes; *capcode; capcode++) {
if ((tcstr = (char *)tgetstr(*capcode,&u)) != NULL && if ((tcstr = (char *)tgetstr(*capcode,&u)) != NULL &&
tcstr != (char *)-1) { tcstr != (char *)-1) {

View File

@ -175,10 +175,6 @@ getterminfo(HashTable ht, char *name)
pm = (Param) zhalloc(sizeof(struct param)); pm = (Param) zhalloc(sizeof(struct param));
pm->nam = dupstring(name); pm->nam = dupstring(name);
pm->flags = PM_READONLY; pm->flags = PM_READONLY;
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
pm->sets.ifn = NULL;
pm->gets.ifn = intgetfn;
pm->unsetfn = NULL; pm->unsetfn = NULL;
pm->ct = 0; pm->ct = 0;
pm->env = NULL; pm->env = NULL;
@ -189,21 +185,29 @@ getterminfo(HashTable ht, char *name)
if (((num = tigetnum(name)) != -1) && (num != -2)) { if (((num = tigetnum(name)) != -1) && (num != -2)) {
pm->u.val = num; pm->u.val = num;
pm->flags |= PM_INTEGER; pm->flags |= PM_INTEGER;
pm->sets.ifn = NULL;
pm->gets.ifn = intgetfn;
} }
else if ((num = tigetflag(name)) != -1) { else if ((num = tigetflag(name)) != -1) {
pm->u.str = num ? dupstring("yes") : dupstring("no"); pm->u.str = num ? dupstring("yes") : dupstring("no");
pm->flags |= PM_SCALAR; pm->flags |= PM_SCALAR;
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
} }
else if ((tistr = (char *)tigetstr(name)) != NULL && tistr != (char *)-1) else if ((tistr = (char *)tigetstr(name)) != NULL && tistr != (char *)-1)
{ {
pm->u.str = dupstring(tistr); pm->u.str = dupstring(tistr);
pm->flags |= PM_SCALAR; pm->flags |= PM_SCALAR;
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
} }
else else
{ {
/* zwarn("no such capability: %s", name, 0); */ /* zwarn("no such capability: %s", name, 0); */
pm->u.str = dupstring(""); pm->u.str = dupstring("");
pm->flags |= PM_UNSET; pm->flags |= PM_UNSET;
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
} }
return (HashNode) pm; return (HashNode) pm;
} }
@ -287,10 +291,6 @@ scanterminfo(HashTable ht, ScanFunc func, int flags)
#endif #endif
pm = (Param) zhalloc(sizeof(struct param)); pm = (Param) zhalloc(sizeof(struct param));
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
pm->sets.ifn = NULL;
pm->gets.ifn = intgetfn;
pm->unsetfn = NULL; pm->unsetfn = NULL;
pm->ct = 0; pm->ct = 0;
pm->env = NULL; pm->env = NULL;
@ -298,6 +298,9 @@ scanterminfo(HashTable ht, ScanFunc func, int flags)
pm->old = NULL; pm->old = NULL;
pm->flags = PM_READONLY | PM_SCALAR; pm->flags = PM_READONLY | PM_SCALAR;
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
for (capname = (char **)boolnames; *capname; capname++) { for (capname = (char **)boolnames; *capname; capname++) {
if ((num = tigetflag(*capname)) != -1) { if ((num = tigetflag(*capname)) != -1) {
pm->u.str = num ? dupstring("yes") : dupstring("no"); pm->u.str = num ? dupstring("yes") : dupstring("no");
@ -305,8 +308,11 @@ scanterminfo(HashTable ht, ScanFunc func, int flags)
func((HashNode) pm, flags); func((HashNode) pm, flags);
} }
} }
pm->flags = PM_READONLY | PM_INTEGER; pm->flags = PM_READONLY | PM_INTEGER;
pm->sets.ifn = NULL;
pm->gets.ifn = intgetfn;
for (capname = (char **)numnames; *capname; capname++) { for (capname = (char **)numnames; *capname; capname++) {
if (((num = tigetnum(*capname)) != -1) && (num != -2)) { if (((num = tigetnum(*capname)) != -1) && (num != -2)) {
pm->u.val = num; pm->u.val = num;
@ -314,8 +320,11 @@ scanterminfo(HashTable ht, ScanFunc func, int flags)
func((HashNode) pm, flags); func((HashNode) pm, flags);
} }
} }
pm->flags = PM_READONLY | PM_SCALAR; pm->flags = PM_READONLY | PM_SCALAR;
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
for (capname = (char **)strnames; *capname; capname++) { for (capname = (char **)strnames; *capname; capname++) {
if ((tistr = (char *)tigetstr(*capname)) != NULL && if ((tistr = (char *)tigetstr(*capname)) != NULL &&
tistr != (char *)-1) { tistr != (char *)-1) {