about summary refs log tree commit diff
path: root/Src/subst.c
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2016-05-08 21:33:24 +0200
committerMikael Magnusson <mikachu@gmail.com>2016-05-08 21:57:06 +0200
commitb7c2ddf65c9175b77bb9efc4ec7de7ef472d7a65 (patch)
treeeca4db8b437ffdb51468a28968ec5f1bdeab2c14 /Src/subst.c
parent546a6b42b3a2b1172fbd099a0fee2864af16461c (diff)
downloadzsh-b7c2ddf65c9175b77bb9efc4ec7de7ef472d7a65.tar.gz
zsh-b7c2ddf65c9175b77bb9efc4ec7de7ef472d7a65.tar.xz
zsh-b7c2ddf65c9175b77bb9efc4ec7de7ef472d7a65.zip
Add typeset -c to control when cached length is used
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 8644ea0d6..cc59c74d4 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -35,6 +35,8 @@
 /**/
 char nulstring[] = {Nularg, '\0'};
 
+int arrcachelen(Param pm);
+    
 /* Do substitutions before fork. These are:
  *  - Process substitution: <(...), >(...), =(...)
  *  - Parameter substitution
@@ -2548,7 +2550,11 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
 		 * necessary joining of arrays until this point
 		 * to avoid the multsub() horror.
 		 */
-		int tmplen = arrlen(v->pm->gsu.a->getfn(v->pm));
+		int tmplen;
+		if (v->pm->node.flags & PM_CACHELEN)
+		    tmplen = arrcachelen(v->pm);
+		else
+		    tmplen = arrlen(v->pm->gsu.a->getfn(v->pm));
 
 		if (v->start < 0)
 		    v->start += tmplen + ((v->flags & VALFLAG_INV) ? 1 : 0);