zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
To: zsh-workers@sunsite.dk
Subject: Re: zcalc bug
Date: Thu, 13 May 2004 21:05:40 +0100	[thread overview]
Message-ID: <20040513200541.7E9B58551@pwstephenson.fsnet.co.uk> (raw)
In-Reply-To: "Matthias Kopfermann"'s message of "Thu, 13 May 2004 20:06:15 +0200." <20040513180615.GB13835@finlandia.infodrom.north.de>


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 <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk


  reply	other threads:[~2004-05-13 20:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-11 12:17 Matthias Kopfermann
2004-05-13 14:04 ` Thomas Köhler
2004-05-13 14:57   ` Peter Stephenson
2004-05-13 15:19     ` Matthias Kopfermann
2004-05-13 15:58       ` Peter Stephenson
2004-05-13 17:29         ` Matthias Kopfermann
2004-05-13 17:47           ` Peter Stephenson
2004-05-13 18:06             ` Matthias Kopfermann
2004-05-13 20:05               ` Peter Stephenson [this message]
2004-05-13 20:03     ` Wayne Davison
2004-05-14  9:23       ` Peter Stephenson
2004-05-15  0:22         ` Wayne Davison
2004-05-18 11:28           ` Peter Stephenson
2004-05-18 19:50             ` [PATCH] local history support, take 2 Wayne Davison
2004-05-18 21:32               ` Wayne Davison
2004-05-19  9:40               ` Peter Stephenson
2004-05-19 16:58                 ` Wayne Davison
2004-05-19 21:37                   ` Peter Stephenson
2004-05-21  1:37                     ` Wayne Davison
2004-05-21  1:44                       ` Wayne Davison
2004-05-21  9:15                       ` Peter Stephenson
2004-05-21 20:06                         ` Wayne Davison

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=20040513200541.7E9B58551@pwstephenson.fsnet.co.uk \
    --to=pws@pwstephenson.fsnet.co.uk \
    --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).