From 0a5702457b4074c72b201fb0eeb68b89763c7874 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 12 Dec 2010 22:44:50 +0000 Subject: 28510: add (z+c+) and (z+C+) parameter flags --- Src/subst.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'Src/subst.c') 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(""); -- cgit 1.4.1