zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Cc: Stephane CHAZELAS <Stephane_CHAZELAS@yahoo.fr>, Tomi.Vainio@Sun.COM
Subject: PATCH: Re: echoti and number of arguments
Date: Tue, 24 Jun 2003 20:04:13 +0200	[thread overview]
Message-ID: <15578.1056477853@gmcs3.local> (raw)
In-Reply-To: <20030519165108.D129@pcchazelas.free.fr>

This patch does basically as suggested in 18551, replacing the quick
fix I sent earlier. I've taken the second approach of hard coding the
list of five capabilities that accept non-integers as parameters. First
parameter is taken to be integer and any others a string.

I've also tried using putp() instead of tputs() to get rid of the
compiler warnings. We can always revert that if any problems crop up.
Anyway, this works on Solaris (32 and 64-bit) and Linux.

Oliver

Index: Src/Modules/terminfo.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v
retrieving revision 1.20
diff -u -r1.20 terminfo.c
--- Src/Modules/terminfo.c	25 Mar 2003 05:33:29 -0000	1.20
+++ Src/Modules/terminfo.c	24 Jun 2003 17:39:03 -0000
@@ -59,8 +59,10 @@
 static int
 bin_echoti(char *name, char **argv, Options ops, int func)
 {
-    char *s, *t, *u;
-    int num, argct;
+    char *s, *t, **u;
+    int arg, num, strarg = 0;
+    long pars[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+    char *strcap[] = { "pfkey", "pfloc", "pfx", "pln", "pfxl", NULL };
 
     s = *argv++;
     /* This depends on the termcap stuff in init.c */
@@ -92,28 +94,32 @@
 	zwarnnam(name, "no such terminfo 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);
+    /* check that the number of arguments provided is not too high */
+    if (arrlen(argv) > 9) {
+        zwarnnam(name, "too many arguments", NULL, 0);
         return 1;
     }
+
+    /* check if we have a capability taking non-integers for parameters */
+    for (u = strcap; *u && !strarg; u++)
+      strarg = !strcmp(s, *u);
+
+    /* get the arguments */
+    for (arg=0; argv[arg]; arg++) {
+	if (strarg && arg > 0)
+            pars[arg] = (long) argv[arg];
+	else
+            pars[arg] = atoi(argv[arg]);
+    }
+
     /* output string, through the proper termcap functions */
-    if (!argct)
-        tputs(t, 1, putraw);
+    if (!arg)
+        putp(t);
     else {
-        num = (argv[1]) ? atoi(argv[1]) : atoi(*argv);
-        tputs(tparm(t, atoi(*argv)), num, putraw);
+        putp(tparm(t, pars[0], pars[1], pars[2], pars[3], pars[4],
+	              pars[5], pars[6], pars[7], pars[8]));
     }
     return 0;
-
 }
 
 /**/

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________


      reply	other threads:[~2003-06-24 18:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-17  8:01 Stephane CHAZELAS
2003-05-17  8:34 ` Stephane CHAZELAS
2003-05-19 10:28 ` Peter Stephenson
2003-05-19 14:51   ` Stephane CHAZELAS
2003-06-24 18:04     ` Oliver Kiddle [this message]

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=15578.1056477853@gmcs3.local \
    --to=okiddle@yahoo.co.uk \
    --cc=Stephane_CHAZELAS@yahoo.fr \
    --cc=Tomi.Vainio@Sun.COM \
    --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).