From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 996 invoked by alias); 23 May 2011 15:56:28 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29351 Received: (qmail 1779 invoked from network); 23 May 2011 15:56:26 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Mon, 23 May 2011 16:56:14 +0100 From: Peter Stephenson To: "Zsh Hackers' List" Subject: Re: Test failure with negative substring offsets Message-ID: <20110523165614.5e638a17@pwslap01u.europe.root.pri> In-Reply-To: References: <20110523161035.747f484d@pwslap01u.europe.root.pri> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.103.11.49] X-Scanned-By: MailControl A_10_80_00 (www.mailcontrol.com) on 10.71.0.126 On Mon, 23 May 2011 17:41:50 +0200 =C4=B0smail D=C3=B6nmez wrote: > It passes for me on 64bit machines and fails on 32bit machines. Hope > that helps. ahhhhh... yes, that was exactly the clue I needed, thank you. stdarg doesn't know the arguments need to be converted to integers to fit the size being claimed in the printf prototype. There might be a few more of these around, hidden by the fact that there's only one integer argument and it's being passed little-endian, so it would fail e.g. on Solaris 32-bit with large file support. The second part is paranoia... the stdarg manual says the va_list ap is undefined after return from a function, so it's safest to run va_end() on it within the function where it's been used. Index: Src/subst.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/zsh/zsh/Src/subst.c,v retrieving revision 1.123 diff -p -u -r1.123 subst.c --- Src/subst.c 19 May 2011 16:24:38 -0000 1.123 +++ Src/subst.c 23 May 2011 15:53:08 -0000 @@ -2892,7 +2892,7 @@ paramsubst(LinkList l, LinkNode n, char=20 length +=3D alen - offset; if (length < 0) { zerr("substring expression: %d < %d", - length + offset, offset); + (int)(length + offset), (int)offset); return NULL; } } else @@ -2942,7 +2942,8 @@ paramsubst(LinkList l, LinkNode n, char=20 } if (length < 0) { zerr("substring expression: %d < %d", - length + given_offset, given_offset); + (int)(length + given_offset), + (int)given_offset); return NULL; } } Index: Src/utils.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/zsh/zsh/Src/utils.c,v retrieving revision 1.258 diff -p -u -r1.258 utils.c --- Src/utils.c 9 May 2011 09:49:09 -0000 1.258 +++ Src/utils.c 23 May 2011 15:53:09 -0000 @@ -155,7 +155,6 @@ VA_DCL VA_START(ap, fmt); VA_GET_ARG(ap, fmt, const char *); zwarning(NULL, fmt, ap); - va_end(ap); errflag =3D 1; } =20 @@ -175,7 +174,6 @@ VA_DCL VA_GET_ARG(ap, cmd, const char *); VA_GET_ARG(ap, fmt, const char *); zwarning(cmd, fmt, ap); - va_end(ap); errflag =3D 1; } =20 @@ -193,7 +191,6 @@ VA_DCL VA_START(ap, fmt); VA_GET_ARG(ap, fmt, const char *); zwarning(NULL, fmt, ap); - va_end(ap); } =20 /**/ @@ -212,7 +209,6 @@ VA_DCL VA_GET_ARG(ap, cmd, const char *); VA_GET_ARG(ap, fmt, const char *); zwarning(cmd, fmt, ap); - va_end(ap); } =20 =20 @@ -236,7 +232,6 @@ VA_DCL fclose(file); } else zerrmsg(stderr, message, ap); - va_end(ap); } =20 #endif /* DEBUG */ @@ -341,6 +336,8 @@ zerrmsg(FILE *file, const char *fmt, va_ } putc('\n', file); fflush(file); + + va_end(ap); } =20 /* Output a single character, for the termcap routines. * --=20 Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, = UK Member of the CSR plc group of companies. CSR plc registered in England and= Wales, registered number 4187346, registered office Churchill House, Cambr= idge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom