Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: (4.0.7) terminfo echo ti args
- X-seq: zsh-workers 19258
- From: Clint Adams <clint@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: (4.0.7) terminfo echo ti args
- Date: Wed, 19 Nov 2003 12:03:31 -0500
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
This (except for the ERR define) has been part of the Debian package for
quite some time now. I imagine that it won't do much for the
portability problems.
Index: Doc/Zsh/mod_terminfo.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_terminfo.yo,v
retrieving revision 1.2
diff -u -r1.2 mod_terminfo.yo
--- Doc/Zsh/mod_terminfo.yo 23 Apr 2001 23:24:19 -0000 1.2
+++ Doc/Zsh/mod_terminfo.yo 19 Nov 2003 17:00:45 -0000
@@ -6,9 +6,9 @@
startitem()
findex(echoti)
cindex(terminfo value, printing)
-item(tt(echoti) var(cap))(
+item(tt(echoti) var(cap) [ var(arg) ])(
Output the terminfo value corresponding to the capability
-var(cap).
+var(cap), instantiated with var(arg) if applicable.
)
enditem()
Index: Src/Modules/terminfo.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v
retrieving revision 1.17.4.2
diff -u -r1.17.4.2 terminfo.c
--- Src/Modules/terminfo.c 22 Aug 2002 16:00:29 -0000 1.17.4.2
+++ Src/Modules/terminfo.c 19 Nov 2003 17:00:45 -0000
@@ -51,6 +51,12 @@
# include <term.h>
# endif
+/* If ERR isn't defined, we probably have bigger problems,
+ * but try this anyway. */
+# ifndef ERR
+# define ERR (-1)
+# endif
+
static Param terminfo_pm;
/* echoti: output a terminfo capability */
@@ -59,8 +65,8 @@
static int
bin_echoti(char *name, char **argv, char *ops, int func)
{
- char *s, *t;
- int num;
+ char *s, *t, *u;
+ int num, argct;
s = *argv++;
/* This depends on the termcap stuff in init.c */
@@ -92,9 +98,28 @@
zwarnnam(name, "no such terminfo capability: %s", s, 0);
return 1;
}
-
- tputs(t, 1, putchar);
+ /* 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(tparm(t, atoi(*argv)), num, putraw);
+ }
return 0;
+
}
/**/
@@ -351,7 +376,10 @@
{
#ifdef HAVE_TIGETSTR
# ifdef HAVE_SETUPTERM
- setupterm((char *)0, 1, (int *)0);
+ int errret;
+
+ if (setupterm((char *)0, 1, &errret) == ERR)
+ return 1;
# endif
if (!createtihash())
Messages sorted by:
Reverse Date,
Date,
Thread,
Author