From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8590 invoked by alias); 13 Dec 2010 01:27:45 -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: 28523 Received: (qmail 12989 invoked from network); 13 Dec 2010 01:27:32 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <101212172652.ZM9617@torch.brasslantern.com> Date: Sun, 12 Dec 2010 17:26:52 -0800 In-reply-to: <20101212224523.423399db@pws-pc.ntlworld.com> Comments: In reply to Peter Stephenson "Re: Another ${(z)param} buglet" (Dec 12, 10:45pm) 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> <20101212224523.423399db@pws-pc.ntlworld.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Another ${(z)param} buglet MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Dec 12, 10:45pm, Peter Stephenson wrote: } } > Here it is implemented and tested, so you can tell me it's not good } > enough. } } As there were no further comments (funny, that...) I've committed it. I'd already made my suggestion about (Z:...:) as an alternative, so it didn't seem necessary to repeat myself. You've now done the difficult bits, so ... Here's a patch that leaves (z+...+) and the rest of PWS's excellent bufferwords tricks, but adds (Z:...:) where ":" can be an arbitrary character or matching braces as with (s:...:) et al. I'm thinking future possible enhancments for (Z) include locally altering the value of $histchars (which is why one might want a delimiter other than "+"), and performing history substitutions on the string. None of that has been done here, yet; also I made only a minimal change to the test script to prove it works, and haven't done doc yet either. What say? This could also easily be tweaked to make (z) and (z:...:), with the :...: having become optional, but we don't have any other cases where the delimited arg string is completely optional [although (l) and (r) have optional sub-parts]. Index: Src/subst.c --- zsh-forge/current/Src/subst.c 2010-12-12 16:22:56.000000000 -0800 +++ Src/subst.c 2010-12-12 16:50:38.000000000 -0800 @@ -1938,10 +1938,16 @@ case 'z': shsplit = 1; - if (s[1] == '+') { - s += 2; - while (*s && *s != '+' && *s != ')' && *s != Outpar) { - switch (*s++) { + if (s[1] != '+') + break; + + case 'Z': + t = get_strarg(++s, &arglen); + if (*t) { + sav = *t; + *t = 0; + while (*++s) { + switch (*s) { case 'c': /* Parse and keep comments */ shsplit = 2; @@ -1956,9 +1962,10 @@ goto flagerr; } } - if (*s != '+') - goto flagerr; - } + *t = sav; + s = t + arglen - 1; + } else + goto flagerr; break; case 'u': --- zsh-forge/current/Test/D04parameter.ztst 2010-12-12 16:22:56.000000000 -0800 +++ Test/D04parameter.ztst 2010-12-12 16:50:37.000000000 -0800 @@ -423,7 +423,7 @@ print "*** Kept ***" print -l ${(z+c+)line} print "*** Removed ***" - print -l ${(z+C+)line} + print -l ${(Z+C+)line} 0:Comments with (z) >*** Normal *** >A