diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2020-02-14 01:58:20 +0100 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2020-02-14 01:58:20 +0100 |
commit | bfc5d42735c1660263904ec5254cccf539a0a458 (patch) | |
tree | 9bbb81b4a53941427e6f9e65ae55027d9108df8c /Src/Zle/compctl.c | |
parent | 74561cc51b8867e43cb2937ab2edfb36e2a829bf (diff) | |
parent | 643de931640e01aa246723d2038328ef33737965 (diff) | |
download | zsh-bfc5d42735c1660263904ec5254cccf539a0a458.tar.gz zsh-bfc5d42735c1660263904ec5254cccf539a0a458.zip |
Merge tag 'zsh-5.7.1-test-3' into debian
Test release: 5.7.1-test-3
Diffstat (limited to 'Src/Zle/compctl.c')
-rw-r--r-- | Src/Zle/compctl.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c index fe87409cb..08355d1b9 100644 --- a/Src/Zle/compctl.c +++ b/Src/Zle/compctl.c @@ -1726,7 +1726,7 @@ static Patprog patcomp, filecomp; * lppre/lpsuf -- the path prefix/suffix, unexpanded * * fpre/fsuf -- prefix/suffix of the pathname component the cursor is in * * prpre -- ppre in expanded form usable for opendir * - * qipre, qisuf-- ingnored quoted string * + * qipre, qisuf-- ignored quoted string * * * * The integer variables hold the lengths of lpre, lsuf, rpre, rsuf, * * fpre, fsuf, lppre, and lpsuf. noreal is non-zero if we have rpre/rsuf. */ @@ -2511,7 +2511,7 @@ makecomplistcmd(char *os, int incmd, int flags) else if (!(cmdstr && (((ccp = (Compctlp) compctltab->getnode(compctltab, cmdstr)) && (cc = ccp->cc)) || - ((s = dupstring(cmdstr)) && remlpaths(&s) && + ((s = dupstring(cmdstr)) && remlpaths(&s, 1) && (ccp = (Compctlp) compctltab->getnode(compctltab, s)) && (cc = ccp->cc))))) { if (flags & CFN_DEFAULT) @@ -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); @@ -3331,13 +3351,11 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd) zlemetaline[end] = save; if (brend) { Brinfo bp; - char *p; - int bl; for (bp = brend; bp; bp = bp->next) { - p = lpsuf + (we - zlemetacs) - bp->qpos - - (bl = strlen(bp->str)); - strcpy(p, p + bl); + char *p2 = lpsuf + (we - zlemetacs) - bp->qpos; + char *p1 = p2 - strlen(bp->str); + memmove(p1, p2, strlen(p2) + 1); } } if (!(lpsuf = strchr(lpsuf, '/')) && sf2) |