From ae583886194c41ad83b7e932c4b6e8cd3d3c5576 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Tue, 10 Dec 2019 10:32:48 +0000
Subject: 44997: GLOB_COMPLETE fix for compctl file completion.
Dashes could cause problems in directory prefixes.
---
ChangeLog | 5 +++++
Src/Zle/compctl.c | 22 +++++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 30c332171..084efd3f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-10 Peter Stephenson
+
+ * 44997: Src/Zle/compctl.c: prefix needed extra munging for
+ hyphen with GLOB_COMPLETE in compctl.
+
2019-12-04 Oliver Kiddle
* 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);
--
cgit 1.4.1