From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28995 invoked from network); 24 Jun 2003 18:03:31 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 24 Jun 2003 18:03:31 -0000 Received: (qmail 3735 invoked by alias); 24 Jun 2003 18:03:25 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18626 Received: (qmail 3727 invoked from network); 24 Jun 2003 18:03:25 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 24 Jun 2003 18:03:25 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [212.125.75.4] by sunsite.dk (MessageWall 1.0.8) with SMTP; 24 Jun 2003 18:3:25 -0000 X-VirusChecked: Checked X-Env-Sender: okiddle@yahoo.co.uk X-Msg-Ref: server-13.tower-1.messagelabs.com!1056477804!45666 X-StarScan-Version: 5.0.6; banners=.,-,- Received: (qmail 13404 invoked from network); 24 Jun 2003 18:03:24 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-13.tower-1.messagelabs.com with SMTP; 24 Jun 2003 18:03:24 -0000 Received: from gmcs3.local ([158.234.142.61]) by iris.logica.co.uk (8.12.3/8.12.3/Debian -4) with ESMTP id h5OI3NxN029758; Tue, 24 Jun 2003 19:03:23 +0100 Received: from gmcs3.local (localhost [127.0.0.1]) by gmcs3.local (8.11.6/8.11.6/SuSE Linux 0.5) with ESMTP id h5OI4DT15580; Tue, 24 Jun 2003 20:04:13 +0200 To: Zsh hackers list In-reply-to: <20030519165108.D129@pcchazelas.free.fr> From: Oliver Kiddle References: <20030517100115.A128@pcchazelas.free.fr> <6877.1053340085@csr.com> <20030519165108.D129@pcchazelas.free.fr> cc: Stephane CHAZELAS , Tomi.Vainio@Sun.COM Subject: PATCH: Re: echoti and number of arguments Date: Tue, 24 Jun 2003 20:04:13 +0200 Message-ID: <15578.1056477853@gmcs3.local> 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 ________________________________________________________________________