From: Peter Stephenson <pws@csr.com>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: regression in $(([##16]...))?
Date: Thu, 16 Oct 2008 10:31:29 +0100 [thread overview]
Message-ID: <20081016103129.77a25e33@news01> (raw)
In-Reply-To: <20081016092308.GB6376@sc.homeunix.net>
On Thu, 16 Oct 2008 10:23:08 +0100
Stephane Chazelas <Stephane_Chazelas@yahoo.fr> wrote:
> ~$ echo $(([##16]12))
> zsh: invalid base (must be 2 to 36 inclusive): -16
> (1)~$ echo $(([##2]12))
> zsh: invalid base (must be 2 to 36 inclusive): -2
>
> (4.3.6-dev-0+1004)
>
> I remember a check for the allowed bases was introduced at some
> point, that may be what broke it.
That feature's so obscure I didn't know it was there and it's never been
tested.
Index: Src/math.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/math.c,v
retrieving revision 1.35
diff -u -r1.35 math.c
--- Src/math.c 26 Sep 2008 09:11:30 -0000 1.35
+++ Src/math.c 16 Oct 2008 09:30:04 -0000
@@ -670,7 +670,8 @@
}
if(*ptr != ']')
goto bofs;
- if (outputradix < 2 || outputradix > 36) {
+ n = (outputradix < 0) ? -outputradix : outputradix;
+ if (n < 2 || n > 36) {
zerr("invalid base (must be 2 to 36 inclusive): %d",
outputradix);
return EOI;
Index: Test/C01arith.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/C01arith.ztst,v
retrieving revision 1.16
diff -u -r1.16 C01arith.ztst
--- Test/C01arith.ztst 12 Jun 2008 13:45:06 -0000 1.16
+++ Test/C01arith.ztst 16 Oct 2008 09:30:04 -0000
@@ -172,3 +172,19 @@
print $(( 3 + "OK"); echo "Worked")
0:not a parse failure because not arithmetic
>+ OK Worked
+
+ fn() {
+ emulate -L zsh
+ print $(( [#16] 255 ))
+ print $(( [##16] 255 ))
+ setopt cbases
+ print $(( [#16] 255 ))
+ print $(( [##16] 255 ))
+ }
+ fn
+0:doubled # in base removes radix
+>16#FF
+>FF
+>0xFF
+>FF
+
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
next prev parent reply other threads:[~2008-10-16 9:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-16 9:23 Stephane Chazelas
2008-10-16 9:31 ` Peter Stephenson [this message]
2008-10-16 10:04 ` Stephane Chazelas
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=20081016103129.77a25e33@news01 \
--to=pws@csr.com \
--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).