aboutsummaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2015-02-22 21:32:08 +0000
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2015-02-22 21:32:08 +0000
commit6fa63a0ce2b2aa31a343ca0841b57895d11b5754 (patch)
treeec3acbb12ccb523f55bab6e92390b4117f9fe238 /Src
parentbcc4ab792d415039fea3afa2976df09f66477721 (diff)
downloadzsh-6fa63a0ce2b2aa31a343ca0841b57895d11b5754.tar.gz
zsh-6fa63a0ce2b2aa31a343ca0841b57895d11b5754.tar.xz
zsh-6fa63a0ce2b2aa31a343ca0841b57895d11b5754.zip
34606: fix up nested arithmetic substitution
Arithmetic within a parameter substitution is a special case that needs fixing with the introduction of the new Inparmath token. Add test.
Diffstat (limited to 'Src')
-rw-r--r--Src/subst.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 176a004ac..f52bcdfc8 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2217,12 +2217,28 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
*/
idbeg = s;
if ((subexp = (inbrace && s[-1] && isstring(*s) &&
- (s[1] == Inbrace || s[1] == Inpar)))) {
+ (s[1] == Inbrace || s[1] == Inpar || s[1] == Inparmath)))) {
int sav;
int quoted = *s == Qstring;
+ int outtok;
val = s++;
- skipparens(*s, *s == Inpar ? Outpar : Outbrace, &s);
+ switch (*s) {
+ case Inbrace:
+ outtok = Outbrace;
+ break;
+ case Inpar:
+ outtok = Outpar;
+ break;
+ case Inparmath:
+ outtok = Outparmath;
+ break;
+ default:
+ /* "Can't Happen" (TM) */
+ DPUTS(1, "Nested substitution: This Can't Happen (TM)");
+ return NULL;
+ }
+ skipparens(*s, outtok, &s);
sav = *s;
*s = 0;
/*