From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-users@zsh.org
Subject: Re: $[ 09.5 ] -- bad math expression
Date: Sun, 2 Dec 2012 21:05:16 +0000 [thread overview]
Message-ID: <20121202210516.66e31219@pws-pc.ntlworld.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1212022323450.27859@oreo.lan>
On Sun, 2 Dec 2012 23:30:34 +1300 (NZDT)
Atom Smasher <atom@smasher.org> wrote:
> with zsh 4.2.1 i get what i'd expect here:
>
> echo "$[ 09.5 ]"
> 9.5
>
> and all math operations work as expected. with zsh 4.3.10, this is broken:
>
> echo "$[ 09.5 ]"
> zsh: bad math expression: operator expected at `.5 '
Oops.
OCTAL_ZEROES looks a bit broken, too. Good job no one uses it.
Index: Src/math.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/math.c,v
retrieving revision 1.43
diff -p -u -r1.43 math.c
--- Src/math.c 11 Sep 2012 16:02:42 -0000 1.43
+++ Src/math.c 2 Dec 2012 21:02:25 -0000
@@ -476,14 +476,11 @@ lexconstant(void)
lastbase = 8;
return NUM;
}
- nptr = ptr2;
}
}
- else
- {
- while (idigit(*nptr) || *nptr == '_')
- nptr++;
- }
+
+ while (idigit(*nptr) || *nptr == '_')
+ nptr++;
if (*nptr == '.' || *nptr == 'e' || *nptr == 'E') {
char *ptr2;
Index: Test/C01arith.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/C01arith.ztst,v
retrieving revision 1.19
diff -p -u -r1.19 C01arith.ztst
--- Test/C01arith.ztst 11 Sep 2012 16:02:42 -0000 1.19
+++ Test/C01arith.ztst 2 Dec 2012 21:02:25 -0000
@@ -233,3 +233,8 @@
>6000000
>5000
>255
+
+ # 3/4 is a multiple of power of two so assume it's represented exactly.
+ print ${$(( 09.75 * 4))%%.*}
+0:leading underscores
+>39
next prev parent reply other threads:[~2012-12-02 23:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-02 10:30 Atom Smasher
2012-12-02 21:05 ` Peter Stephenson [this message]
2012-12-02 21:59 ` Bart Schaefer
2012-12-02 22:15 ` Atom Smasher
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=20121202210516.66e31219@pws-pc.ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-users@zsh.org \
/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).