zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: (4.0.7) terminfo echo ti args
@ 2003-11-19 17:03 Clint Adams
  2003-11-20  9:31 ` Oliver Kiddle
  0 siblings, 1 reply; 2+ messages in thread
From: Clint Adams @ 2003-11-19 17:03 UTC (permalink / raw)
  To: zsh-workers

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())


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PATCH: (4.0.7) terminfo echo ti args
  2003-11-19 17:03 PATCH: (4.0.7) terminfo echo ti args Clint Adams
@ 2003-11-20  9:31 ` Oliver Kiddle
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Kiddle @ 2003-11-20  9:31 UTC (permalink / raw)
  To: Clint Adams; +Cc: zsh-workers

Clint Adams wrote:
> 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.

> +/* If ERR isn't defined, we probably have bigger problems,
> + * but try this anyway. */
> +# ifndef ERR
> +#  define ERR (-1)
> +# endif

Well, doing that would fix the compile problem that has been mentioned
for FreeBSD and that I have on my Debian machine. Not the nicest way
but it'd work just as long as no system uses something other than -1
for ERR.

The rest of this looks like the 4.1 patch for echoti to take arguments.
It lacks the changes I made in 18626 in response to the thread starting
at 18544. I take it from the subject line that you're suggesting this
is applied to 4.0. I really don't think we should be making changes
like this on the 4.0 branch. Especially not this shortly before a 4.0.8
release. terminfo/termcap are one of the more common causes of
portability problems and 4.0 is at least working at the moment.

Oliver


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-11-20  9:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-19 17:03 PATCH: (4.0.7) terminfo echo ti args Clint Adams
2003-11-20  9:31 ` Oliver Kiddle

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).