summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2019-12-10 10:32:48 +0000
committerPeter Stephenson <p.stephenson@samsung.com>2019-12-10 10:32:48 +0000
commitae583886194c41ad83b7e932c4b6e8cd3d3c5576 (patch)
tree93089ef15fe91c9c4498fc85fedd7dfdc46557c5
parent06e27e940aa876dbcb5b9e0ded487bed2e282447 (diff)
downloadzsh-ae583886194c41ad83b7e932c4b6e8cd3d3c5576.tar.gz
zsh-ae583886194c41ad83b7e932c4b6e8cd3d3c5576.tar.xz
zsh-ae583886194c41ad83b7e932c4b6e8cd3d3c5576.zip
44997: GLOB_COMPLETE fix for compctl file completion.
Dashes could cause problems in directory prefixes.
-rw-r--r--ChangeLog5
-rw-r--r--Src/Zle/compctl.c22
2 files changed, 26 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 30c332171..084efd3f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-10  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* 44997: Src/Zle/compctl.c: prefix needed extra munging for
+	hyphen with GLOB_COMPLETE in compctl.
+
 2019-12-04  Oliver Kiddle  <okiddle@yahoo.co.uk>
 
 	* 44976: Src/Zle/zle_main.c: describe-key-briefly in visual mode
diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c
index f242e1b28..1dcec387d 100644
--- a/Src/Zle/compctl.c
+++ b/Src/Zle/compctl.c
@@ -3178,7 +3178,27 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd)
     /* Compute line prefix/suffix. */
     lpl = offs;
     lpre = zhalloc(lpl + 1);
-    memcpy(lpre, s, lpl);
+    if (comppatmatch)
+    {
+	int ccount;
+	char *psrc, *pdst;
+	for (ccount = 0, psrc = s, pdst = lpre;
+	     ccount < lpl;
+	     ++ccount, ++psrc, ++pdst)
+	{
+	    if (*psrc == Meta)
+	    {
+		ccount++;
+		*pdst++ = *psrc++;
+		*pdst = *psrc;
+	    } else if (*psrc == Dash)
+		*pdst = '-';
+	    else
+		*pdst = *psrc;
+	}
+    }
+    else
+	memcpy(lpre, s, lpl);
     lpre[lpl] = '\0';
     qlpre = quotename(lpre);
     lsuf = dupstring(s + offs);