summaryrefslogtreecommitdiff
path: root/Src/subst.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-12-12 22:44:50 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-12-12 22:44:50 +0000
commit0a5702457b4074c72b201fb0eeb68b89763c7874 (patch)
tree0fff9ded114ba57fd4131fa4a43860cafd94b91b /Src/subst.c
parent72d1045da5f38380a8b4bd6fcb02baac21e0a4cf (diff)
downloadzsh-0a5702457b4074c72b201fb0eeb68b89763c7874.tar.gz
zsh-0a5702457b4074c72b201fb0eeb68b89763c7874.zip
28510: add (z+c+) and (z+C+) parameter flags
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 031a1affd..799682df2 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1556,6 +1556,10 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
* The (z) flag, nothing to do with SH_WORD_SPLIT which is tied
* spbreak, see above; fairly straighforward in use but c.f.
* the comment for mods.
+ *
+ * This ultimately becomes zleparse during lexical analysis, via
+ * the comments argument to bufferwords(). It's got nothing
+ * to do with zle.
*/
int shsplit = 0;
/*
@@ -1934,6 +1938,27 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
case 'z':
shsplit = 1;
+ if (s[1] == '+') {
+ s += 2;
+ while (*s && *s != '+' && *s != ')' && *s != Outpar) {
+ switch (*s++) {
+ case 'c':
+ /* Parse and keep comments */
+ shsplit = 2;
+ break;
+
+ case 'C':
+ /* Parse and remove comments */
+ shsplit = 3;
+ break;
+
+ default:
+ goto flagerr;
+ }
+ }
+ if (*s != '+')
+ goto flagerr;
+ }
break;
case 'u':
@@ -3207,10 +3232,10 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
if (isarr) {
char **ap;
for (ap = aval; *ap; ap++)
- list = bufferwords(list, *ap, NULL);
+ list = bufferwords(list, *ap, NULL, shsplit-1);
isarr = 0;
} else
- list = bufferwords(NULL, val, NULL);
+ list = bufferwords(NULL, val, NULL, shsplit-1);
if (!list || !firstnode(list))
val = dupstring("");