about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2016-09-17 06:32:58 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2016-09-20 17:59:19 +0000
commitbd94e13f34db02b0fed2414b54cc6787407436ad (patch)
tree4d3af8b3b026a90192776f4aff1359dc5abf0f68 /Src
parentc8de0af35935602370cc79193d0e0d53971250d4 (diff)
downloadzsh-bd94e13f34db02b0fed2414b54cc6787407436ad.tar.gz
zsh-bd94e13f34db02b0fed2414b54cc6787407436ad.tar.xz
zsh-bd94e13f34db02b0fed2414b54cc6787407436ad.zip
39372: compadd: Match -P prefix all-or-nothing rather than greedily.
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/compcore.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 2f9fb3308..05d27068a 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -2029,7 +2029,7 @@ addmatches(Cadata dat, char **argv)
     char **aign = NULL, **dparr = NULL, *oaq = autoq, *oppre = dat->ppre;
     char *oqp = qipre, *oqs = qisuf, qc, **disp = NULL, *ibuf = NULL;
     char **arrays = NULL;
-    int lpl, lsl, pl, sl, bcp = 0, bcs = 0, bpadd = 0, bsadd = 0;
+    int lpl, lsl, sl, bcp = 0, bcs = 0, bpadd = 0, bsadd = 0;
     int ppl = 0, psl = 0, ilen = 0;
     int llpl = 0, llsl = 0, nm = mnum, gflags = 0, ohp = haspattern;
     int isexact, doadd, ois = instring, oib = inbackt;
@@ -2193,9 +2193,12 @@ addmatches(Cadata dat, char **argv)
 
 	    /* Test if there is an existing -P prefix. */
 	    if (dat->pre && *dat->pre) {
-		pl = pfxlen(dat->pre, lpre);
-		llpl -= pl;
-		lpre += pl;
+		int prefix_length = pfxlen(dat->pre, lpre);
+		if (dat->pre[prefix_length] == '\0') {
+		    /* $compadd_args[-P] is a prefix of ${PREFIX}. */
+		    llpl -= prefix_length;
+		    lpre += prefix_length;
+		}
 	    }
 	}
 	/* Now duplicate the strings we have from the command line. */