From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11124 invoked by alias); 13 Dec 2010 10:15:19 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28526 Received: (qmail 14158 invoked from network); 13 Dec 2010 10:15:17 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Mon, 13 Dec 2010 10:15:06 +0000 From: Peter Stephenson To: Subject: Re: Another ${(z)param} buglet Message-ID: <20101213101506.64c737ed@pwslap01u.europe.root.pri> In-Reply-To: <20101209201913.43a94f54@pws-pc.ntlworld.com> References: <101207203441.ZM4340@torch.brasslantern.com> <20101208175103.40d6cc29@pwslap01u.europe.root.pri> <101209074233.ZM8003@torch.brasslantern.com> <20101209181632.27d47e95@pwslap01u.europe.root.pri> <20101209201913.43a94f54@pws-pc.ntlworld.com> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 13 Dec 2010 10:15:06.0937 (UTC) FILETIME=[9D9B2A90:01CB9AAE] X-Scanned-By: MailControl A_10_80_00 (www.mailcontrol.com) on 10.68.0.122 On Thu, 9 Dec 2010 20:19:13 +0000 Peter Stephenson wrote: > On Thu, 9 Dec 2010 18:16:32 +0000 > Peter Stephenson wrote: > > The best I can think of is extending the syntax to append options, > > a bit like (q) can have the q multiple or a - added, but maybe less > > gross e.g. explicit option flags like z+c+ to turn on comment > > handling (and possibly z+C+ to strip comments). '+' appears not to > > be taken so would work without complications and there's a mnemonic > > that there's more to come (compared with "(q-)"). > > Here it is implemented and tested, so you can tell me it's not good > enough. One tweak to this version of the patch: if you stripped comments and there was one right at the end of the string, the end of line was treated as a newline so you got a ';', which is inconsistent with what you get without the comment, and indeed with the comment retained as a string. Index: Src/lex.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/lex.c,v retrieving revision 1.58 diff -p -u -r1.58 lex.c --- Src/lex.c 12 Dec 2010 22:44:51 -0000 1.58 +++ Src/lex.c 13 Dec 2010 10:12:40 -0000 @@ -800,7 +800,15 @@ gettok(void) hwbegin(0); hwaddc('\n'); addtoline('\n'); - peek = NEWLIN; + /* + * If splitting a line and removing comments, + * we don't want a newline token since it's + * treated specially. + */ + if (zleparse == 3 && lexstop) + peek = ENDINPUT; + else + peek = NEWLIN; } } return peek; Index: Test/D04parameter.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v retrieving revision 1.48 diff -p -u -r1.48 D04parameter.ztst --- Test/D04parameter.ztst 12 Dec 2010 22:44:51 -0000 1.48 +++ Test/D04parameter.ztst 13 Dec 2010 10:12:40 -0000 @@ -456,6 +456,12 @@ >another >one + line='with comment # at the end' + print -l ${(z+C+)line} +0:Test we don't get an additional newline token +>with +>comment + psvar=(dog) setopt promptsubst foo='It shouldn'\''t $(happen) to a %1v.' -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom