* PATCH: termcap/terminfo support in modules
@ 2000-12-03 20:48 Clint Adams
2000-12-04 16:38 ` Bart Schaefer
0 siblings, 1 reply; 12+ messages in thread
From: Clint Adams @ 2000-12-03 20:48 UTC (permalink / raw)
To: zsh-workers
This is my attempt to get the echotc builtin out of the core
and to provide a terminfo equivalent, as well as a terminfo parameter.
The goal is to be able to do something like this in a startup script:
bindkey -M emacs "$terminfo[kdch1]" delete-char
There is an obvious lack of error-checking, but I digress.
Documentation will follow in some number of hours.
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.38
diff -u -r1.38 builtin.c
--- Src/builtin.c 2000/11/11 19:50:28 1.38
+++ Src/builtin.c 2000/12/03 20:33:07
@@ -55,7 +55,6 @@
BUILTIN("disable", 0, bin_enable, 0, -1, BIN_DISABLE, "afmr", NULL),
BUILTIN("disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL),
BUILTIN("echo", BINF_PRINTOPTS | BINF_ECHOPTS, bin_print, 0, -1, BIN_ECHO, "neE", "-"),
- BUILTIN("echotc", 0, bin_echotc, 1, -1, 0, NULL, NULL),
BUILTIN("emulate", 0, bin_emulate, 1, 1, 0, "LR", NULL),
BUILTIN("enable", 0, bin_enable, 0, -1, BIN_ENABLE, "afmr", NULL),
BUILTIN("eval", BINF_PSPECIAL, bin_eval, 0, -1, BIN_EVAL, NULL, NULL),
@@ -2896,76 +2895,6 @@
fputc(ops['N'] ? '\0' : '\n', fout);
if (fout != stdout)
fclose(fout);
- return 0;
-}
-
-/* echotc: output a termcap */
-
-/**/
-int
-bin_echotc(char *name, char **argv, char *ops, int func)
-{
- char *s, buf[2048], *t, *u;
- int num, argct;
-
- s = *argv++;
- if (termflags & TERM_BAD)
- return 1;
- if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
- return 1;
- /* if the specified termcap has a numeric value, display it */
- if ((num = tgetnum(s)) != -1) {
- printf("%d\n", num);
- return 0;
- }
- /* if the specified termcap is boolean, and set, say so *
- * ncurses can tell if an existing boolean capability is *
- * off so in this case we print "no". */
-#if !defined(NCURSES_VERSION) || !defined(COLOR_PAIR)
- if (tgetflag(s) > 0) {
- puts("yes");
- return (0);
- }
-#else /* NCURSES_VERSION && COLOR_PAIR */
- switch (tgetflag(s)) {
- case -1:
- break;
- case 0:
- puts("no");
- return 0;
- default:
- puts("yes");
- return 0;
- }
-#endif /* NCURSES_VERSION && COLOR_PAIR */
- /* get a string-type capability */
- u = buf;
- t = tgetstr(s, &u);
- if (!t || !*t) {
- /* capability doesn't exist, or (if boolean) is off */
- zwarnnam(name, "no such capability: %s", s, 0);
- return 1;
- }
- /* count the number of arguments required */
- for (argct = 0, u = t; *u; u++)
- if (*u == '%') {
- if (u++, (*u == 'd' || *u == '2' || *u == '3' || *u == '.' ||
- *u == '+'))
- argct++;
- }
- /* check that the number of arguments provided is correct */
- if (arrlen(argv) != argct) {
- zwarnnam(name, (arrlen(argv) < argct) ? "not enough arguments" :
- "too many arguments", NULL, 0);
- return 1;
- }
- /* output string, through the proper termcap functions */
- if (!argct)
- tputs(t, 1, putraw);
- else {
- num = (argv[1]) ? atoi(argv[1]) : atoi(*argv);
- tputs(tgoto(t, atoi(*argv), num), num, putraw);
- }
return 0;
}
Index: Src/Modules/termcap.c
===================================================================
RCS file: termcap.c
diff -N termcap.c
--- /dev/null Tue May 5 13:32:27 1998
+++ termcap.c Sun Dec 3 12:33:07 2000
@@ -0,0 +1,134 @@
+/*
+ * termcap.c - termcap manipulation through curses
+ *
+ * This file is part of zsh, the Z shell.
+ *
+ * Copyright (c) 1992-1997 Paul Falstad
+ * All rights reserved.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and to distribute modified versions of this software for any
+ * purpose, provided that the above copyright notice and the following
+ * two paragraphs appear in all copies of this software.
+ *
+ * In no event shall Paul Falstad or the Zsh Development Group be liable
+ * to any party for direct, indirect, special, incidental, or consequential
+ * damages arising out of the use of this software and its documentation,
+ * even if Paul Falstad and the Zsh Development Group have been advised of
+ * the possibility of such damage.
+ *
+ * Paul Falstad and the Zsh Development Group specifically disclaim any
+ * warranties, including, but not limited to, the implied warranties of
+ * merchantability and fitness for a particular purpose. The software
+ * provided hereunder is on an "as is" basis, and Paul Falstad and the
+ * Zsh Development Group have no obligation to provide maintenance,
+ * support, updates, enhancements, or modifications.
+ *
+ */
+
+#include "termcap.mdh"
+#include "termcap.pro"
+
+/* echotc: output a termcap */
+
+/**/
+int
+bin_echotc(char *name, char **argv, char *ops, int func)
+{
+ char *s, buf[2048], *t, *u;
+ int num, argct;
+
+ s = *argv++;
+ if (termflags & TERM_BAD)
+ return 1;
+ if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
+ return 1;
+ /* if the specified termcap has a numeric value, display it */
+ if ((num = tgetnum(s)) != -1) {
+ printf("%d\n", num);
+ return 0;
+ }
+ /* if the specified termcap is boolean, and set, say so *
+ * ncurses can tell if an existing boolean capability is *
+ * off so in this case we print "no". */
+#if !defined(NCURSES_VERSION) || !defined(COLOR_PAIR)
+ if (tgetflag(s) > 0) {
+ puts("yes");
+ return (0);
+ }
+#else /* NCURSES_VERSION && COLOR_PAIR */
+ switch (tgetflag(s)) {
+ case -1:
+ break;
+ case 0:
+ puts("no");
+ return 0;
+ default:
+ puts("yes");
+ return 0;
+ }
+#endif /* NCURSES_VERSION && COLOR_PAIR */
+ /* get a string-type capability */
+ u = buf;
+ t = tgetstr(s, &u);
+ if (!t || !*t) {
+ /* capability doesn't exist, or (if boolean) is off */
+ zwarnnam(name, "no such capability: %s", s, 0);
+ return 1;
+ }
+ /* count the number of arguments required */
+ for (argct = 0, u = t; *u; u++)
+ if (*u == '%') {
+ if (u++, (*u == 'd' || *u == '2' || *u == '3' || *u == '.' ||
+ *u == '+'))
+ argct++;
+ }
+ /* check that the number of arguments provided is correct */
+ if (arrlen(argv) != argct) {
+ zwarnnam(name, (arrlen(argv) < argct) ? "not enough arguments" :
+ "too many arguments", NULL, 0);
+ return 1;
+ }
+ /* output string, through the proper termcap functions */
+ if (!argct)
+ tputs(t, 1, putraw);
+ else {
+ num = (argv[1]) ? atoi(argv[1]) : atoi(*argv);
+ tputs(tgoto(t, atoi(*argv), num), num, putraw);
+ }
+ return 0;
+}
+
+static struct builtin bintab[] = {
+ BUILTIN("echotc", 0, bin_echotc, 1, -1, 0, NULL, NULL),
+};
+
+/**/
+int
+setup_(Module m)
+{
+ return 0;
+}
+
+/**/
+int
+boot_(Module m)
+{
+ return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
+}
+
+/**/
+int
+cleanup_(Module m)
+{
+ deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
+ return 0;
+}
+
+/**/
+int
+finish_(Module m)
+{
+ return 0;
+}
Index: Src/Modules/termcap.mdd
===================================================================
RCS file: termcap.mdd
diff -N termcap.mdd
--- /dev/null Tue May 5 13:32:27 1998
+++ termcap.mdd Sun Dec 3 12:33:07 2000
@@ -0,0 +1,7 @@
+name=zsh/termcap
+link=either
+load=yes
+
+autobins="echotc"
+
+objects="termcap.o"
Index: Src/Modules/terminfo.c
===================================================================
RCS file: terminfo.c
diff -N terminfo.c
--- /dev/null Tue May 5 13:32:27 1998
+++ terminfo.c Sun Dec 3 12:33:07 2000
@@ -0,0 +1,226 @@
+/*
+ * terminfo.c - parameter interface to terminfo via curses
+ *
+ * This file is part of zsh, the Z shell.
+ *
+ * Copyright (c) 2000 Sven Wishnowsky, Clint Adams
+ * All rights reserved.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and to distribute modified versions of this software for any
+ * purpose, provided that the above copyright notice and the following
+ * two paragraphs appear in all copies of this software.
+ *
+ * In no event shall Sven Wishnowsky, Clint Adams or the Zsh Development Group
+ * be liable to any party for direct, indirect, special, incidental, or
+ * consequential damages arising out of the use of this software and its
+ * documentation, even if Sven Wishnowsky, Clint Adams and the Zsh
+ * Development Group have been advised of the possibility of such damage.
+ *
+ * Sven Wishnowsky, Clint Adams and the Zsh Development Group specifically
+ * disclaim any warranties, including, but not limited to, the implied
+ * warranties of merchantability and fitness for a particular purpose.
+ * The software provided hereunder is on an "as is" basis, and Sven
+ * Wishnowsky, Clint Adams and the Zsh Development Group have no obligation
+ * to provide maintenance, support, updates, enhancements, or modifications.
+ *
+ */
+
+#include "terminfo.mdh"
+#include "terminfo.pro"
+
+static char terminfo_nam[] = "terminfo";
+static Param terminfo_pm;
+
+/* echoti: output a terminfo capability */
+
+/**/
+int
+bin_echoti(char *name, char **argv, char *ops, int func)
+{
+ char *s, buf[2048], *t, *u;
+ int num, argct;
+
+ s = *argv++;
+ 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;
+}
+
+/* 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),
+ };
+
+/* This says if we are cleaning up when the module is unloaded. */
+
+static int incleanup;
+
+/* Empty dummy function for special hash parameters. */
+
+/**/
+static void
+shempty(void)
+{
+}
+
+/* Create a simple special hash parameter. */
+
+/**/
+static Param
+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;
+ ht->addnode = (AddNodeFunc) shempty;
+ ht->getnode = ht->getnode2 = getterminfo;
+ ht->removenode = (RemoveNodeFunc) shempty;
+ ht->disablenode = NULL;
+ ht->enablenode = NULL;
+ ht->freenode = (FreeNodeFunc) shempty;
+ ht->printnode = printparamnode;
+ ht->scantab = scanterminfo;
+
+ return (terminfo_pm = pm);
+}
+
+/**/
+static HashNode
+getterminfo(HashTable ht, char *name)
+{
+ int len, num;
+ char *tistr;
+ Param pm = NULL;
+
+ if (termflags & TERM_BAD)
+ return 1;
+ if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
+ return 1;
+
+ unmetafy(name, &len);
+
+ pm = (Param) zhalloc(sizeof(struct param));
+ pm->nam = dupstring(name);
+ pm->flags = PM_READONLY;
+ pm->sets.cfn = NULL;
+ pm->gets.cfn = strgetfn;
+ pm->unsetfn = NULL;
+ pm->ct = 0;
+ pm->env = NULL;
+ pm->ename = NULL;
+ pm->old = NULL;
+ pm->level = 0;
+
+ if (((num = tigetnum(name)) != -1) && (num != -2)) {
+ pm->u.val = num;
+ pm->flags |= PM_INTEGER;
+ }
+ else if ((num = tigetflag(name)) != -1) {
+ pm->u.str = num ? dupstring("yes") : dupstring("no");
+ pm->flags |= PM_SCALAR;
+ }
+ else if ((tistr = 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;
+ }
+ return (HashNode) pm;
+
+}
+
+/**/
+static void
+scanterminfo(HashTable ht, ScanFunc func, int flags)
+{
+return 0;
+}
+
+/**/
+int
+setup_(Module m)
+{
+ incleanup = 0;
+
+ return 0;
+}
+
+/**/
+int
+boot_(Module m)
+{
+ return !createtihash() || !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
+}
+
+/**/
+int
+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);
+ }
+ deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
+ return 0;
+}
+
+/**/
+int
+finish_(Module m)
+{
+ return 0;
+}
Index: Src/Modules/terminfo.mdd
===================================================================
RCS file: terminfo.mdd
diff -N terminfo.mdd
--- /dev/null Tue May 5 13:32:27 1998
+++ terminfo.mdd Sun Dec 3 12:33:07 2000
@@ -0,0 +1,8 @@
+name=zsh/terminfo
+link=either
+load=yes
+
+autobins="echoti"
+autoparams="terminfo"
+
+objects="terminfo.o"
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: PATCH: termcap/terminfo support in modules
2000-12-03 20:48 PATCH: termcap/terminfo support in modules Clint Adams
@ 2000-12-04 16:38 ` Bart Schaefer
2000-12-04 16:46 ` Clint Adams
0 siblings, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 2000-12-04 16:38 UTC (permalink / raw)
To: Clint Adams, zsh-workers
On Dec 3, 3:48pm, Clint Adams wrote:
} Subject: PATCH: termcap/terminfo support in modules
}
} This is my attempt to get the echotc builtin out of the core
} and to provide a terminfo equivalent, as well as a terminfo parameter.
Lots of errors for me:
../../../zsh-3.1.6/Src/Modules/terminfo.c: In function `bin_echoti':
../../../zsh-3.1.6/Src/Modules/terminfo.c:68: warning: assignment makes pointer from integer without a cast
../../../zsh-3.1.6/Src/Modules/terminfo.c:43: warning: unused variable `argct'
../../../zsh-3.1.6/Src/Modules/terminfo.c:42: warning: unused variable `u'
../../../zsh-3.1.6/Src/Modules/terminfo.c:42: warning: unused variable `buf'
../../../zsh-3.1.6/Src/Modules/terminfo.c: In function `getterminfo':
../../../zsh-3.1.6/Src/Modules/terminfo.c:140: warning: return makes pointer from integer without a cast
../../../zsh-3.1.6/Src/Modules/terminfo.c:142: warning: return makes pointer from integer without a cast
../../../zsh-3.1.6/Src/Modules/terminfo.c:166: warning: assignment makes pointer from integer without a cast
../../../zsh-3.1.6/Src/Modules/terminfo.c: In function `scanterminfo':
../../../zsh-3.1.6/Src/Modules/terminfo.c:185: warning: `return' with a value, in function returning void
And then:
Modules/terminfo.o: In function `bin_echoti':
/usr/src/local/zsh/zsh-3.1.6-build/Src/Modules/../../../zsh-3.1.6/Src/Modules/terminfo.c:51: undefined reference to `tigetnum'
/usr/src/local/zsh/zsh-3.1.6-build/Src/Modules/../../../zsh-3.1.6/Src/Modules/terminfo.c:56: undefined reference to `tigetflag'
/usr/src/local/zsh/zsh-3.1.6-build/Src/Modules/../../../zsh-3.1.6/Src/Modules/terminfo.c:68: undefined reference to `tigetstr'
Modules/terminfo.o: In function `getterminfo':
/usr/src/local/zsh/zsh-3.1.6-build/Src/Modules/../../../zsh-3.1.6/Src/Modules/terminfo.c:158: undefined reference to `tigetnum'
/usr/src/local/zsh/zsh-3.1.6-build/Src/Modules/../../../zsh-3.1.6/Src/Modules/terminfo.c:162: undefined reference to `tigetflag'
/usr/src/local/zsh/zsh-3.1.6-build/Src/Modules/../../../zsh-3.1.6/Src/Modules/terminfo.c:166: undefined reference to `tigetstr'
It appears that configure on my RH5.2 box decides that only -ltermcap is
necessary, but the tiget* functions are in libcurses. I find it somewhat
disappointing that zsh now has to be linked with curses; the line editor
has so studiously avoided using curses for screen management ...
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: PATCH: termcap/terminfo support in modules
2000-12-04 16:38 ` Bart Schaefer
@ 2000-12-04 16:46 ` Clint Adams
2000-12-04 17:05 ` Peter Stephenson
0 siblings, 1 reply; 12+ messages in thread
From: Clint Adams @ 2000-12-04 16:46 UTC (permalink / raw)
To: Bart Schaefer; +Cc: zsh-workers
> It appears that configure on my RH5.2 box decides that only -ltermcap is
> necessary, but the tiget* functions are in libcurses. I find it somewhat
> disappointing that zsh now has to be linked with curses; the line editor
> has so studiously avoided using curses for screen management ...
We could just make the terminfo module not be built if tiget* are undefined.
Couldn't we?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: PATCH: termcap/terminfo support in modules
2000-12-04 16:46 ` Clint Adams
@ 2000-12-04 17:05 ` Peter Stephenson
2000-12-04 17:27 ` Bart Schaefer
0 siblings, 1 reply; 12+ messages in thread
From: Peter Stephenson @ 2000-12-04 17:05 UTC (permalink / raw)
To: Zsh hackers list
> We could just make the terminfo module not be built if tiget* are undefined.
> Couldn't we?
Add a configure test and test it in the `link=...' line in terminfo.mdd.
For example,
link='if test "x$ac_cv_have_tiget" = xyes; then echo either; else echo no; fi'
--
Peter Stephenson <pws@csr.com> Software Engineer
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: PATCH: termcap/terminfo support in modules
2000-12-04 17:05 ` Peter Stephenson
@ 2000-12-04 17:27 ` Bart Schaefer
2000-12-05 0:23 ` Clint Adams
0 siblings, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 2000-12-04 17:27 UTC (permalink / raw)
To: Zsh hackers list
On Dec 4, 5:05pm, Peter Stephenson wrote:
} Subject: Re: PATCH: termcap/terminfo support in modules
}
} > We could just make the terminfo module not be built if tiget* are undefined.
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.
Other random things I noticed:
Indentation is really messed up in terminfo.c, starting at about line 52.
`man curs_terminfo' on my system says that strings returned by tigetstr()
et al. should always be output using tputs(), but terminfo.c outputs them
with printf().
`man curs_terminfo' also implies that setupterm() must be called before
using any of the other terminfo functions. THere also may be a conflict
on global variables named `lines' and `columns' but maybe that's already
been dealt with as I know zsh does link with curses on some OSs.
} Add a configure test and test it in the `link=...' line in terminfo.mdd.
}
} link='if test "x$ac_cv_have_tiget" = xyes; then echo either; else echo no; fi'
That's pretty spiffy.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: PATCH: termcap/terminfo support in modules
2000-12-04 17:27 ` Bart Schaefer
@ 2000-12-05 0:23 ` Clint Adams
2000-12-05 2:17 ` Vin Shelton
2000-12-05 10:04 ` PATCH: termcap/terminfo support in modules Peter Stephenson
0 siblings, 2 replies; 12+ messages in thread
From: Clint Adams @ 2000-12-05 0:23 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Zsh hackers list
> 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"
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: PATCH: termcap/terminfo support in modules
2000-12-05 0:23 ` Clint Adams
@ 2000-12-05 2:17 ` Vin Shelton
2000-12-05 4:21 ` PATCH: texinfo (Re: PATCH: termcap/terminfo support in modules) Bart Schaefer
2000-12-05 10:04 ` PATCH: termcap/terminfo support in modules Peter Stephenson
1 sibling, 1 reply; 12+ messages in thread
From: Vin Shelton @ 2000-12-05 2:17 UTC (permalink / raw)
To: Clint Adams; +Cc: Bart Schaefer, Zsh hackers list
I'm getting the following errors on 'make install' now:
./tzsh.texi:8149: Cross reference to nonexistent node `The zsh/terminfo Module'.
./tzsh.texi:8146: Cross reference to nonexistent node `The zsh/termcap Module'.
-vin
^ permalink raw reply [flat|nested] 12+ messages in thread
* PATCH: texinfo (Re: PATCH: termcap/terminfo support in modules)
2000-12-05 2:17 ` Vin Shelton
@ 2000-12-05 4:21 ` Bart Schaefer
0 siblings, 0 replies; 12+ messages in thread
From: Bart Schaefer @ 2000-12-05 4:21 UTC (permalink / raw)
To: Zsh hackers list
On Dec 4, 9:17pm, Vin Shelton wrote:
} Subject: Re: PATCH: termcap/terminfo support in modules
}
}
} ./tzsh.texi:8149: Cross reference to nonexistent node `The zsh/terminfo Module'.
} ./tzsh.texi:8146: Cross reference to nonexistent node `The zsh/termcap Module'.
Index: Doc/Makefile.in
===================================================================
@@ -59,6 +59,7 @@
Zsh/mod_computil.yo \
Zsh/mod_deltochar.yo Zsh/mod_example.yo Zsh/mod_files.yo \
Zsh/mod_mapfile.yo Zsh/mod_mathfunc.yo Zsh/mod_parameter.yo Zsh/mod_sched.yo \
+Zsh/mod_termcap.yo Zsh/mod_terminfo.yo \
Zsh/mod_stat.yo Zsh/mod_zftp.yo Zsh/mod_zle.yo Zsh/mod_zleparameter.yo \
Zsh/mod_zutil.yo Zsh/mod_zprof.yo Zsh/mod_zpty.yo
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: PATCH: termcap/terminfo support in modules
2000-12-05 0:23 ` Clint Adams
2000-12-05 2:17 ` Vin Shelton
@ 2000-12-05 10:04 ` Peter Stephenson
2000-12-05 10:42 ` Peter Stephenson
1 sibling, 1 reply; 12+ messages in thread
From: Peter Stephenson @ 2000-12-05 10:04 UTC (permalink / raw)
To: Zsh hackers list
> 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"
Those should really be forward quotes: configure tests specially for a
$link which contains spaces and re-evaluates it, while anywhere else
zsh.mdd is used the values tested for don't make sense. But, thinking
about it, you probably get away with it since the value of $link from the
.mdd file isn't used once config.modules exist.
--
Peter Stephenson <pws@csr.com> Software Engineer
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: PATCH: termcap/terminfo support in modules
2000-12-05 10:04 ` PATCH: termcap/terminfo support in modules Peter Stephenson
@ 2000-12-05 10:42 ` Peter Stephenson
2000-12-05 10:55 ` Peter Stephenson
0 siblings, 1 reply; 12+ messages in thread
From: Peter Stephenson @ 2000-12-05 10:42 UTC (permalink / raw)
To: Zsh hackers list
I wrote:
> Those should really be forward quotes
A bigger problem is that the configure variable is wrongly named.
Index: Src/Modules/terminfo.mdd
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.mdd,v
retrieving revision 1.2
diff -u -r1.2 terminfo.mdd
--- Src/Modules/terminfo.mdd 2000/12/05 00:28:46 1.2
+++ Src/Modules/terminfo.mdd 2000/12/05 10:39:35
@@ -1,5 +1,5 @@
name=zsh/terminfo
-link=`if test "x$ac_cv_have_tigetstr" = xyes; then echo either; else echo no; fi`
+link='if test "x$ac_cv_func_tigetstr" = xyes; then echo either; else echo no; fi'
load=yes
autobins="echoti"
--
Peter Stephenson <pws@csr.com> Software Engineer
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: PATCH: termcap/terminfo support in modules
2000-12-05 10:42 ` Peter Stephenson
@ 2000-12-05 10:55 ` Peter Stephenson
2000-12-06 1:11 ` Clint Adams
0 siblings, 1 reply; 12+ messages in thread
From: Peter Stephenson @ 2000-12-05 10:55 UTC (permalink / raw)
To: Zsh hackers list
> A bigger problem is that the configure variable is wrongly named.
Sorry to keep sending short messages on the same thing, but:
% echoti foo
zsh: segmentation fault (core dumped) zsh
The culprit appears to be tigetstr(s) on Solaris 2.6 returning 0xffffffff,
which looks a lot like -1. Indeed, although the manual entry claims
blithely at the end `routines that return pointers always return NULL on
error', it seems this returns -1 to indicate `not a string value'.
Index: Src/Modules/terminfo.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v
retrieving revision 1.2
diff -u -r1.2 terminfo.c
--- Src/Modules/terminfo.c 2000/12/05 00:28:46 1.2
+++ Src/Modules/terminfo.c 2000/12/05 10:55:33
@@ -67,7 +67,7 @@
/* get a string-type capability */
t = (char *)tigetstr(s);
- if (!t || !*t) {
+ if (!t || t == (char *)-1 || !*t) {
/* capability doesn't exist, or (if boolean) is off */
zwarnnam(name, "no such terminfo capability: %s", s, 0);
return 1;
--
Peter Stephenson <pws@csr.com> Software Engineer
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: PATCH: termcap/terminfo support in modules
2000-12-05 10:55 ` Peter Stephenson
@ 2000-12-06 1:11 ` Clint Adams
0 siblings, 0 replies; 12+ messages in thread
From: Clint Adams @ 2000-12-06 1:11 UTC (permalink / raw)
To: Peter Stephenson; +Cc: Zsh hackers list
> The culprit appears to be tigetstr(s) on Solaris 2.6 returning 0xffffffff,
> which looks a lot like -1. Indeed, although the manual entry claims
> blithely at the end `routines that return pointers always return NULL on
> error', it seems this returns -1 to indicate `not a string value'.
The same applies to $terminfo:
Index: Src/Modules/terminfo.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v
retrieving revision 1.3
diff -u -r1.3 terminfo.c
--- Src/Modules/terminfo.c 2000/12/05 11:00:08 1.3
+++ Src/Modules/terminfo.c 2000/12/06 01:01:45
@@ -165,7 +165,7 @@
pm->u.str = num ? dupstring("yes") : dupstring("no");
pm->flags |= PM_SCALAR;
}
- else if ((tistr = (char *)tigetstr(name)) != NULL)
+ else if ((tistr = (char *)tigetstr(name)) != NULL && tistr != (char *)-1)
{
pm->u.str = dupstring(tistr);
pm->flags |= PM_SCALAR;
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2000-12-06 1:11 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-03 20:48 PATCH: termcap/terminfo support in modules Clint Adams
2000-12-04 16:38 ` Bart Schaefer
2000-12-04 16:46 ` Clint Adams
2000-12-04 17:05 ` Peter Stephenson
2000-12-04 17:27 ` Bart Schaefer
2000-12-05 0:23 ` Clint Adams
2000-12-05 2:17 ` Vin Shelton
2000-12-05 4:21 ` PATCH: texinfo (Re: PATCH: termcap/terminfo support in modules) Bart Schaefer
2000-12-05 10:04 ` PATCH: termcap/terminfo support in modules Peter Stephenson
2000-12-05 10:42 ` Peter Stephenson
2000-12-05 10:55 ` Peter Stephenson
2000-12-06 1:11 ` Clint Adams
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).