about summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-25 10:28:11 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-25 10:28:11 +0000
commit6623bb41b98142c24607790dc8311435d1c33257 (patch)
tree6a9ca6c9a47515acec91959747edad70e1d55f05 /Src/Zle
parentd49da606702363f0eb5615a341126c2dbe562849 (diff)
downloadzsh-6623bb41b98142c24607790dc8311435d1c33257.tar.gz
zsh-6623bb41b98142c24607790dc8311435d1c33257.tar.xz
zsh-6623bb41b98142c24607790dc8311435d1c33257.zip
report prefix/suffix of parameter expansion in IPREFIX/ISUFFIX; make _expand use them to be able to expand $foo (10909)
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/compcore.c31
-rw-r--r--Src/Zle/compresult.c2
2 files changed, 27 insertions, 6 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index d5dee0dca..0c989c427 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -492,6 +492,8 @@ after_complete(Hookdef dummy, Compldat dat)
 
 /* This calls the given completion widget function. */
 
+static int parwb, parwe, paroffs;
+
 /**/
 static void
 callcompfunc(char *s, char *fn)
@@ -637,9 +639,24 @@ callcompfunc(char *s, char *fn)
 	    compsuffix = ztrdup(ss);
 	}
 	zsfree(compiprefix);
-	compiprefix = ztrdup("");
 	zsfree(compisuffix);
-	compisuffix = ztrdup("");
+	if (parwb < 0) {
+	    compiprefix = ztrdup("");
+	    compisuffix = ztrdup("");
+	} else {
+	    int l;
+
+	    compiprefix = (char *) zalloc((l = wb - parwb) + 1);
+	    memcpy(compiprefix, line + parwb, l);
+	    compiprefix[l] = '\0';
+	    compisuffix = (char *) zalloc((l = parwe - we) + 1);
+	    memcpy(compisuffix, line + we, l);
+	    compisuffix[l] = '\0';
+
+	    wb = parwb;
+	    we = parwe;
+	    offs = paroffs;
+	}
 	zsfree(compqiprefix);
 	compqiprefix = ztrdup(qipre ? qipre : "");
 	zsfree(compqisuffix);
@@ -829,10 +846,16 @@ static int
 makecomplist(char *s, int incmd, int lst)
 {
     char *p;
+    int owb = wb, owe = we, ooffs = offs;
 
     /* Inside $... ? */
-    if (compfunc && (p = check_param(s, 0, 0)))
+    if (compfunc && (p = check_param(s, 0, 0))) {
 	s = p;
+	parwb = owb;
+	parwe = owe;
+	paroffs = ooffs;
+    } else
+	parwb = -1;
 
     linwhat = inwhat;
 
@@ -1073,7 +1096,7 @@ check_param(char *s, int set, int test)
 	    }
 	    /* Save the prefix. */
 	    if (compfunc) {
-		parflags = (br >= 2 ? CMF_PARBR : 0);
+		parflags = (br >= 2 ? CMF_PARBR | (nest ? CMF_PARNEST : 0) : 0);
 		sav = *b;
 		*b = '\0';
 		untokenize(parpre = ztrdup(s));
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index 87e1f7278..3875987c5 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -1030,8 +1030,6 @@ accept_last(void)
 	else if (cs > ll)
 	    cs = ll;
 	inststrlen(" ", 1, 1);
-	if (parpre)
-	    inststr(parpre);
 	minfo.insc = minfo.len = 0;
 	minfo.pos = cs;
 	minfo.we = 1;