Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: regression in $(([##16]...))?
- X-seq: zsh-workers 25905
- From: Peter Stephenson <pws@xxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: Re: regression in $(([##16]...))?
- Date: Thu, 16 Oct 2008 10:31:29 +0100
- In-reply-to: <20081016092308.GB6376@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Organization: CSR
- References: <20081016092308.GB6376@xxxxxxxxxxxxxxx>
On Thu, 16 Oct 2008 10:23:08 +0100
Stephane Chazelas <Stephane_Chazelas@xxxxxxxx> 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@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author