diff options
author | Bart Schaefer <barts@users.sourceforge.net> | 2001-05-30 15:39:31 +0000 |
---|---|---|
committer | Bart Schaefer <barts@users.sourceforge.net> | 2001-05-30 15:39:31 +0000 |
commit | 14be3dd5e46eaf1d3b8488730d2fb5cf704594bc (patch) | |
tree | b2ad5d81698bb617ff7062924f51a827b4e55634 /Src | |
parent | 13476e2a866281214bb27d97547ec5c94e37b12c (diff) | |
download | zsh-14be3dd5e46eaf1d3b8488730d2fb5cf704594bc.tar.gz zsh-14be3dd5e46eaf1d3b8488730d2fb5cf704594bc.tar.xz zsh-14be3dd5e46eaf1d3b8488730d2fb5cf704594bc.zip |
Improve gettermcap().
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Modules/termcap.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c index ddba69a6d..032335fb3 100644 --- a/Src/Modules/termcap.c +++ b/Src/Modules/termcap.c @@ -109,7 +109,7 @@ bin_echotc(char *name, char **argv, char *ops, int func) /* get a string-type capability */ u = buf; t = tgetstr(s, &u); - if (!t || !*t) { + if (t == (char *)-1 || !t || !*t) { /* capability doesn't exist, or (if boolean) is off */ zwarnnam(name, "no such capability: %s", s, 0); return 1; @@ -225,15 +225,34 @@ gettermcap(HashTable ht, char *name) pm->level = 0; u = buf; + /* logic in the following cascade copied from echotc, above */ + if ((num = tgetnum(name)) != -1) { pm->u.val = num; pm->flags |= PM_INTEGER; + return (HashNode) pm; } - else if ((num = tgetflag(name)) != -1) { - pm->u.str = num ? dupstring("yes") : dupstring("no"); +#if !defined(NCURSES_VERSION) || !defined(COLOR_PAIR) + if ((num = tgetflag(name)) > 0) { + pm->u.str = dupstring("yes"); pm->flags |= PM_SCALAR; + return (HashNode) pm; } - else if ((tcstr = (char *)tgetstr(name,&u)) != NULL && tcstr != (char *)-1) +#else /* NCURSES_VERSION && COLOR_PAIR */ + switch (tgetflag(name)) { + case -1: + break; + case 0: + pm->u.str = dupstring("no"); + pm->flags |= PM_SCALAR; + return (HashNode) pm; + default: + pm->u.str = dupstring("yes"); + pm->flags |= PM_SCALAR; + return (HashNode) pm; + } +#endif /* NCURSES_VERSION && COLOR_PAIR */ + if ((tcstr = tgetstr(name, &u)) != NULL && tcstr != (char *)-1) { pm->u.str = dupstring(tcstr); pm->flags |= PM_SCALAR; @@ -262,7 +281,7 @@ scantermcap(HashTable ht, ScanFunc func, int flags) "mi", "ms", "nx", "xb", "NP", "ND", "NR", "os", "5i", "YD", "YE", "es", "hz", "ul", "xo", NULL}; #endif - + #ifndef HAVE_NUMCODES static char *numcodes[] = { "co", "it", "lh", "lw", "li", "lm", "sg", "ma", "Co", "pa", "MW", @@ -322,7 +341,7 @@ scantermcap(HashTable ht, ScanFunc func, int flags) pm->ename = NULL; pm->old = NULL; u = buf; - + pm->flags = PM_READONLY | PM_SCALAR; for (capcode = (char **)boolcodes; *capcode; capcode++) { if ((num = tgetflag(*capcode)) != -1) { @@ -331,7 +350,7 @@ scantermcap(HashTable ht, ScanFunc func, int flags) func((HashNode) pm, flags); } } - + pm->flags = PM_READONLY | PM_INTEGER; for (capcode = (char **)numcodes; *capcode; capcode++) { if ((num = tgetnum(*capcode)) != -1) { @@ -340,7 +359,7 @@ scantermcap(HashTable ht, ScanFunc func, int flags) func((HashNode) pm, flags); } } - + pm->flags = PM_READONLY | PM_SCALAR; for (capcode = (char **)strcodes; *capcode; capcode++) { if ((tcstr = (char *)tgetstr(*capcode,&u)) != NULL && |