summaryrefslogtreecommitdiff
path: root/Src/Zle/compcore.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle/compcore.c')
-rw-r--r--Src/Zle/compcore.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 52b0c173f..8eca39447 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -1610,9 +1610,11 @@ set_comp_sep(void)
inpush(dupstrspace(tmp), 0, NULL);
zlemetaline = tmp;
/*
- * Length of temporary string, calculated above.
+ * tl is the length of temporary string, calculated above.
+ * It seems zlemetall need not include the 'x' added at the cursor.
+ * addedx is taken care of in function gotword() (lex.c).
*/
- zlemetall = tl;
+ zlemetall = tl - addedx;
strinbeg(0);
noaliases = 1;
do {
@@ -1638,7 +1640,7 @@ set_comp_sep(void)
p[-1] = '\0';
}
}
- if (tok == ENDINPUT || tok == LEXERR)
+ if (tok == ENDINPUT)
break;
if (tokstr && *tokstr) {
for (p = tokstr; dq && *p; p++) {
@@ -1667,9 +1669,9 @@ set_comp_sep(void)
if (!got && !lexflags) {
DPUTS(!p, "no current word in substr");
got = 1;
- cur = i;
- swb = wb - 1 - dq - sq - dolq;
- swe = we - 1 - dq - sq - dolq;
+ cur = countlinknodes(foo) - 1; /* cur is 0 offset */
+ swb = wb - dq - sq - dolq;
+ swe = we - dq - sq - dolq;
sqq = lsq;
soffs = zlemetacs - swb - css;
DPUTS2(p[soffs] != 'x', "expecting 'x' at offset %d of \"%s\"",
@@ -1901,7 +1903,11 @@ set_comp_sep(void)
p = compwords[i] = (char *) getdata(n);
untokenize(p);
}
- compcurrent = cur + 1;
+ /* The current position shouldn't exceed the new word count */
+ if ((compcurrent = cur + 1) > i) {
+ DPUTS2(1, "compcurrent=%d > number_of_words=%d", compcurrent, i);
+ compcurrent = i;
+ }
compwords[i] = NULL;
}
instring = ois;
@@ -3550,6 +3556,8 @@ freematches(Cmgroup g, int cm)
}
free(g->expls);
}
+ if (g->widths)
+ free(g->widths);
zsfree(g->name);
free(g);