summaryrefslogtreecommitdiff
path: root/Src/subst.c
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2015-05-28 02:27:03 +0200
committerAxel Beckert <abe@deuxchevaux.org>2015-05-28 02:27:03 +0200
commitfd2ef9a80430c1f4f4ae222af228b485c484dd64 (patch)
tree58e2e652beebfed85a7e0545cf81a24f2c74cf09 /Src/subst.c
parentf14d3594049e553de8d61e5fc1d2fa245410a867 (diff)
parentfd786a5c8abf1942a05ed8c470b06cc0b4aa5174 (diff)
downloadzsh-fd2ef9a80430c1f4f4ae222af228b485c484dd64.tar.gz
zsh-fd2ef9a80430c1f4f4ae222af228b485c484dd64.zip
Merge branch 'upstream' and tag 'zsh-5.0.7-dev-4' into 'debian'
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/Src/subst.c b/Src/subst.c
index f52bcdfc8..d4a04b8e5 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -259,10 +259,19 @@ stringsubst(LinkList list, LinkNode node, int pf_flags, int asssub)
#endif
str--;
} else if (c == Inparmath) {
- /* Math substitution of the form $((...)) */
+ /*
+ * Math substitution of the form $((...)).
+ * These can be nested, for goodness sake...
+ */
+ int mathpar = 1;
str[-1] = '\0';
- while (*str != Outparmath && *str)
+ while (mathpar && *str) {
str++;
+ if (*str == Outparmath)
+ mathpar--;
+ else if (*str == Inparmath)
+ mathpar++;
+ }
if (*str != Outparmath) {
zerr("failed to find end of math substitution");
return NULL;
@@ -1592,7 +1601,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
/* combination of (L), (U) and (C) flags. */
int casmod = CASMOD_NONE;
/*
- * quotemod says we are doing either (q) (positive), (Q) (negative)
+ * quotemod says we are doing either (q/b) (positive), (Q) (negative)
* or not (0). quotetype counts the q's for the first case.
* quoterr is simply (X) but gets passed around a lot because the
* combination (eX) needs it.
@@ -1845,7 +1854,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
break;
case 'q':
- if (quotetype == QT_DOLLARS)
+ if (quotetype == QT_DOLLARS ||
+ quotetype == QT_BACKSLASH_PATTERN)
goto flagerr;
if (s[1] == '-') {
if (quotemod)
@@ -1861,6 +1871,12 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
quotemod++, quotetype++;
}
break;
+ case 'b':
+ if (quotemod || quotetype != QT_NONE)
+ goto flagerr;
+ quotemod = 1;
+ quotetype = QT_BACKSLASH_PATTERN;
+ break;
case 'Q':
quotemod--;
break;
@@ -3460,7 +3476,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
if (quotemod) {
int pre = 0, post = 0;
- if (quotemod > 0 && quotetype > QT_BACKSLASH) {
+ if (quotemod > 0) {
switch (quotetype)
{
case QT_DOLLARS:
@@ -3471,6 +3487,9 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
case QT_SINGLE_OPTIONAL:
/* quotes will be added for us */
+ case QT_BACKSLASH:
+ case QT_BACKSLASH_PATTERN:
+ /* no quotes */
break;
default: