From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13244 invoked from network); 13 May 2004 20:01:04 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.86) by ns1.primenet.com.au with SMTP; 13 May 2004 20:01:04 -0000 Received: (qmail 12357 invoked from network); 13 May 2004 20:00:52 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 May 2004 20:00:52 -0000 Received: (qmail 7076 invoked by alias); 13 May 2004 20:00:49 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19941 Received: (qmail 7063 invoked from network); 13 May 2004 20:00:48 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 13 May 2004 20:00:45 -0000 Received: (qmail 12216 invoked from network); 13 May 2004 20:00:45 -0000 Received: from cmailg4.svr.pol.co.uk (195.92.195.174) by a.mx.sunsite.dk with SMTP; 13 May 2004 20:00:43 -0000 Received: from modem-197.minnesota.dialup.pol.co.uk ([62.137.74.197] helo=pwstephenson.fsnet.co.uk) by cmailg4.svr.pol.co.uk with esmtp (Exim 4.14) id 1BOMNl-0003Pk-QO for zsh-workers@sunsite.dk; Thu, 13 May 2004 21:00:42 +0100 Received: by pwstephenson.fsnet.co.uk (Postfix, from userid 501) id 7E9B58551; Thu, 13 May 2004 16:05:41 -0400 (EDT) Received: from pwstephenson.fsnet.co.uk (localhost [127.0.0.1]) by pwstephenson.fsnet.co.uk (Postfix) with ESMTP id 51F18851A for ; Thu, 13 May 2004 21:05:41 +0100 (BST) To: zsh-workers@sunsite.dk Subject: Re: zcalc bug In-reply-to: "Matthias Kopfermann"'s message of "Thu, 13 May 2004 20:06:15 +0200." <20040513180615.GB13835@finlandia.infodrom.north.de> Date: Thu, 13 May 2004 21:05:40 +0100 From: Peter Stephenson Message-Id: <20040513200541.7E9B58551@pwstephenson.fsnet.co.uk> X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: * X-Spam-Status: No, hits=1.5 required=6.0 tests=RCVD_IN_SORBS autolearn=no version=2.63 X-Spam-Hits: 1.5 Matthias Kopfermann wrote: > i saw a sweet output when doing > > print $((3*4,)) > > BUG: math: not enough wallabies in outback. Fair dinkum blue (sorry, Geoff)... The comment above it says /* Make sure anyone seeing this message reports it. */ so this worked. The real bug is that it continues the calculation and outputs 12, without reporting a user error. I think this is the fix. The precedence of comma was the highest precedence, which incorrectly indicated it didn't need an argument. It simply(?) needs to be at an intervening precedence, without disturbing the other ordering. Index: Src/math.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/math.c,v retrieving revision 1.19 diff -u -r1.19 math.c --- Src/math.c 11 Aug 2003 10:45:10 -0000 1.19 +++ Src/math.c 13 May 2004 19:59:42 -0000 @@ -168,8 +168,8 @@ 0, 16, 0 }; -#define TOPPREC 17 -#define ARGPREC (TOPPREC-1) +#define TOPPREC 18 +#define ARGPREC 16 static int type[TOKCOUNT] = { Index: Test/C01arith.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/C01arith.ztst,v retrieving revision 1.7 diff -u -r1.7 C01arith.ztst --- Test/C01arith.ztst 17 Dec 2003 20:47:40 -0000 1.7 +++ Test/C01arith.ztst 13 May 2004 19:59:42 -0000 @@ -110,3 +110,23 @@ print $(( )) 0:empty math parse e.g. $(( )) acts like a zero >0 + + print $(( a = )) +1:empty assignment +?(eval):1: bad math expression: operand expected at `' + + print $(( 3, )) +1:empty right hand of comma +?(eval):1: bad math expression: operand expected at `' + + print $(( 3,,4 )) +1:empty middle of comma +?(eval):1: bad math expression: operand expected at `,4 ' + + print $(( (3 + 7, 4), 5 )) +0:commas and parentheses, part 1 +>5 + + print $(( 5, (3 + 7, 4) )) +0:commas and parentheses, part 1 +>4 -- Peter Stephenson Work: pws@csr.com Web: http://www.pwstephenson.fsnet.co.uk