From: Clint Adams <clint@zsh.org>
To: zsh-workers@sunsite.dk
Subject: PATCH: (4.0.7) terminfo echo ti args
Date: Wed, 19 Nov 2003 12:03:31 -0500 [thread overview]
Message-ID: <20031119170331.GA13715@scowler.net> (raw)
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())
next reply other threads:[~2003-11-19 17:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-19 17:03 Clint Adams [this message]
2003-11-20 9:31 ` Oliver Kiddle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20031119170331.GA13715@scowler.net \
--to=clint@zsh.org \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).