From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21703 invoked from network); 23 Jan 2007 15:36:31 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 23 Jan 2007 15:36:31 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 51731 invoked from network); 23 Jan 2007 15:36:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 23 Jan 2007 15:36:26 -0000 Received: (qmail 18437 invoked by alias); 23 Jan 2007 15:36:23 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23128 Received: (qmail 18428 invoked from network); 23 Jan 2007 15:36:22 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 23 Jan 2007 15:36:22 -0000 Received: (qmail 51422 invoked from network); 23 Jan 2007 15:36:22 -0000 Received: from cluster-d.mailcontrol.com (217.69.20.190) by a.mx.sunsite.dk with SMTP; 23 Jan 2007 15:36:16 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly45d.srv.mailcontrol.com (MailControl) with ESMTP id l0NFYCoC028266 for ; Tue, 23 Jan 2007 15:36:14 GMT Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Tue, 23 Jan 2007 15:35:34 +0000 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.8/8.13.4) with ESMTP id l0NFZUgL020857 for ; Tue, 23 Jan 2007 15:35:30 GMT Received: from csr.com (pws@localhost) by news01.csr.com (8.13.8/8.13.8/Submit) with ESMTP id l0NFZSwY020854 for ; Tue, 23 Jan 2007 15:35:29 GMT Message-Id: <200701231535.l0NFZSwY020854@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: Zsh Hackers Subject: Re: Bug: Wrong completion of $(( $(!cmd In-reply-to: <070123072344.ZM12121@torch.brasslantern.com> References: <20070122234306.GA24536@primenet.com.au> <200701231304.l0ND4b3t011195@news01.csr.com> <070123072344.ZM12121@torch.brasslantern.com> Comments: In-reply-to Bart Schaefer message dated "Tue, 23 Jan 2007 07:23:44 -0800." Date: Tue, 23 Jan 2007 15:35:28 +0000 From: Peter Stephenson X-OriginalArrivalTime: 23 Jan 2007 15:35:34.0344 (UTC) FILETIME=[1F73A480:01C73F04] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-07-06-80 (www.mailcontrol.com) on 10.68.0.155 Bart Schaefer wrote: > On Jan 23, 1:04pm, Peter Stephenson wrote: > } > } The problem is somewhere here (in lex.c). If dquote_parse() returns > } non-zero it's an error indication, not a character, so the hungetc(c) > } is definitely wrong in that case. > > I don't think that's true. I presume you mean the second statement. If you've got any evidence against the first statement I'd like to see it. > If you look at the tail end of dquote_parse() > you'll see that if lexstop is false the return value of dquote_parse() is > overloaded -- it's both an error indication AND the most recently read > character from the input stream. That's what hungetc() is trying to put > back in that spot in cmd_or_math(). > > That doesn't make it correct, but that's what's going on. There must be > (or have been at some past time) some other reason higher up the parse > tree why that final character needed to be retained. I looked a bit further and it seems it's used in gettokstr() to hungetc() a character when we have an error. I don't understand what that buys when we can't parse the input anyway, particularly since we don't even know if it's a valid character because of the other way of setting the value; could it have been a hack to get history lines to be stored properly after an error? I recall we improved that at some point, so this hack may not be necessary. I traced it (the "err = c" thing in dquote_parse()) back in the code to 3.0.0, which is before the use in cmd_or_math() that is causing the problem, so it wasn't introduced specifically for that, and cmd_or_math() was roughly the way it now is right back in 3.0.8. Consequently (although what you say is true) I don't see anything wrong with the proposed change. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview