From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7999 invoked from network); 19 Nov 2003 17:03:43 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 19 Nov 2003 17:03:43 -0000 Received: (qmail 16391 invoked by alias); 19 Nov 2003 17:03:34 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19258 Received: (qmail 16374 invoked from network); 19 Nov 2003 17:03:33 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 19 Nov 2003 17:03:33 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [216.254.112.142] by sunsite.dk (MessageWall 1.0.8) with SMTP; 19 Nov 2003 17:3:32 -0000 Received: by acolyte.scowler.net (Postfix, from userid 1000) id 09FEB7003B; Wed, 19 Nov 2003 12:03:31 -0500 (EST) Date: Wed, 19 Nov 2003 12:03:31 -0500 From: Clint Adams To: zsh-workers@sunsite.dk Subject: PATCH: (4.0.7) terminfo echo ti args Message-ID: <20031119170331.GA13715@scowler.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i 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 # 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())