From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Another ${(z)param} buglet
Date: Sun, 12 Dec 2010 17:26:52 -0800 [thread overview]
Message-ID: <101212172652.ZM9617@torch.brasslantern.com> (raw)
In-Reply-To: <20101212224523.423399db@pws-pc.ntlworld.com>
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
next prev parent reply other threads:[~2010-12-13 1:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-08 4:34 Bart Schaefer
2010-12-08 17:51 ` Peter Stephenson
2010-12-09 15:42 ` Bart Schaefer
2010-12-09 18:16 ` Peter Stephenson
2010-12-09 20:19 ` Peter Stephenson
2010-12-12 22:45 ` Peter Stephenson
2010-12-13 1:26 ` Bart Schaefer [this message]
2010-12-13 9:47 ` Peter Stephenson
2010-12-13 17:35 ` Bart Schaefer
2010-12-13 18:12 ` Peter Stephenson
2010-12-14 10:20 ` Peter Stephenson
2010-12-14 16:57 ` Bart Schaefer
2010-12-13 5:16 ` Bart Schaefer
2010-12-13 10:15 ` Peter Stephenson
2010-12-09 20:25 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=101212172652.ZM9617@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).