From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19620 invoked from network); 16 Oct 2008 09:31:49 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 16 Oct 2008 09:31:49 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 88878 invoked from network); 16 Oct 2008 09:31:45 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 16 Oct 2008 09:31:45 -0000 Received: (qmail 19643 invoked by alias); 16 Oct 2008 09:31:40 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25905 Received: (qmail 19627 invoked from network); 16 Oct 2008 09:31:39 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 16 Oct 2008 09:31:39 -0000 Received: from cluster-g.mailcontrol.com (cluster-g.mailcontrol.com [208.87.233.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 7EA7180524C0 for ; Thu, 16 Oct 2008 11:31:35 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly21g.srv.mailcontrol.com (MailControl) with ESMTP id m9G9VVrb015456 for ; Thu, 16 Oct 2008 10:31:32 +0100 Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Thu, 16 Oct 2008 10:31:30 +0100 Date: Thu, 16 Oct 2008 10:31:29 +0100 From: Peter Stephenson To: Zsh hackers list Subject: Re: regression in $(([##16]...))? Message-ID: <20081016103129.77a25e33@news01> In-Reply-To: <20081016092308.GB6376@sc.homeunix.net> References: <20081016092308.GB6376@sc.homeunix.net> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 16 Oct 2008 09:31:30.0970 (UTC) FILETIME=[F8DB47A0:01C92F71] X-Scanned-By: MailControl A-08-50-15 (www.mailcontrol.com) on 10.71.0.131 X-Virus-Scanned: ClamAV 0.92.1/8433/Thu Oct 16 08:56:26 2008 on bifrost X-Virus-Status: Clean On Thu, 16 Oct 2008 10:23:08 +0100 Stephane Chazelas 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 Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070