Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fix pointer math in join_sub
The original report states:
mkdir -p /tmp/x && cd /tmp/x && touch ab-xyFOO ac-xyBAR
cat -xy<TAB>
autocompletes to `aB-xy`, and
mkdir -p /tmp/t && cd /tmp/t && touch 1abc 2abc
cat a<TAB>
autocompletes to `Aabc`.
check_cmdata has already advanced md->str by md->len when sfx is true,
so doing it again here is incorrect. bld_line then wants a pointer to
the start of the string, so subtract the length when sfx is true, since
it is an end pointer in that case (as is done in many other places in
this function already).
---
I think the analysis makes sense, if a bit wordy. I tried to condense it
in my above commit message. I also simplified the patch, I assume the
LLM thought it needed a copy of nw since it is advanced below, but it
removed the advance so actually the copy isn't needed.
Src/Zle/compmatch.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index 7e04112945..0f878038bd 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -2217,7 +2217,7 @@ join_sub(Cmdata md, char *str, int len, int *mlen, int sfx, int join)
int t;
if (sfx) {
- ow += ol; nw += nl;
+ ow += ol;
}
for (t = 0, ms = bmatchers; ms && !t; ms = ms->next) {
mp = ms->matcher;
@@ -2262,7 +2262,7 @@ join_sub(Cmdata md, char *str, int len, int *mlen, int sfx, int join)
else
mw = nw - (sfx ? mp->wlen : 0);
- if ((bl = bld_line(mp, line, mw, (t ? nw : ow),
+ if ((bl = bld_line(mp, line, mw, (t ? nw - (sfx ? nl : 0) : str),
(t ? nl : ol), sfx))) {
/* Yep, one of the lines matched the other
* string. */
--
2.38.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author