From: gak@klanderman.net (Greg Klanderman)
To: zsh-workers@sunsite.dk (Zsh list)
Subject: PATCH: Re: compctl "-y" argument busted in 4.0.6
Date: Tue, 4 Feb 2003 21:08:07 -0500 (EST) [thread overview]
Message-ID: <15936.29191.196889.6099@phl.itasoftware.com> (raw)
In-Reply-To: <1030204100553.ZM16338@candle.brasslantern.com>
>>>>> Bart Schaefer <schaefer@brasslantern.com> writes:
> On Feb 3, 8:12pm, Greg Klanderman wrote:
> }
> } % setopt autolist noautomenu nolistbeep listambiguous listtypes
> } % compctl -k "(foo bar baz)" -y "(FOO BAR BAZ)" foobar
> } % foobar <TAB>
> }
> } displays no completions at all!
> This is fixed in 4.1.0-dev-6. I don't know exactly what fixed it; there
> are no obvious patches meant for it, but it must have been something in
> one of zsh-workers/17195 or 16483.
Thanks Bart,
I have attached a patch for 4.0.6 in case anyone is interested. Once
I tracked the problem to the calclist() function in
Src/Zle/compresult.c, it was pretty hopeless trying to figure out what
was going on so this patch is simply the version of that same function
from 4.1.0-dev7 massaged back to work under the 4.0.6 codebase. I've
been using it a few hours here without problem.
My patch from zsh-workers/18191 could also be applied on top of this
if anyone so desires.
thanks,
Greg
--- Zle/compresult.c.orig Tue Feb 4 17:45:27 2003
+++ Zle/compresult.c Tue Feb 4 17:45:47 2003
@@ -1443,44 +1443,46 @@
}
m->flags &= ~CMF_HIDE;
- if (m->disp) {
- if (m->flags & CMF_DISPLINE) {
- nlines += 1 + printfmt(m->disp, 0, 0, 0);
- g->flags |= CGF_HASDL;
- } else {
- l = niceztrlen(m->disp);
- ndisp++;
- if (l > glong)
- glong = l;
- if (l < gshort)
- gshort = l;
- totl += l;
- mlens[m->gnum] = l;
- }
- nlist++;
- if (!(m->flags & CMF_PACKED))
- g->flags &= ~CGF_PACKED;
- if (!(m->flags & CMF_ROWS))
- g->flags &= ~CGF_ROWS;
- } else if (showall || !(m->flags & (CMF_NOLIST | CMF_MULT))) {
+ if (showall || !(m->flags & (CMF_NOLIST | CMF_MULT))) {
if ((m->flags & (CMF_NOLIST | CMF_MULT)) &&
(!m->str || !*m->str)) {
m->flags |= CMF_HIDE;
continue;
}
- l = niceztrlen(m->str);
- ndisp++;
- if (l > glong)
- glong = l;
- if (l < gshort)
- gshort = l;
- totl += l;
- mlens[m->gnum] = l;
- nlist++;
- if (!(m->flags & CMF_PACKED))
- g->flags &= ~CGF_PACKED;
- if (!(m->flags & CMF_ROWS))
- g->flags &= ~CGF_ROWS;
+ if (m->disp) {
+ if (m->flags & CMF_DISPLINE) {
+ nlines += 1 + printfmt(m->disp, 0, 0, 0);
+ g->flags |= CGF_HASDL;
+ } else {
+ l = niceztrlen(m->disp);
+ ndisp++;
+ if (l > glong)
+ glong = l;
+ if (l < gshort)
+ gshort = l;
+ totl += l;
+ mlens[m->gnum] = l;
+ }
+ nlist++;
+ if (!(m->flags & CMF_PACKED))
+ g->flags &= ~CGF_PACKED;
+ if (!(m->flags & CMF_ROWS))
+ g->flags &= ~CGF_ROWS;
+ } else {
+ l = niceztrlen(m->str);
+ ndisp++;
+ if (l > glong)
+ glong = l;
+ if (l < gshort)
+ gshort = l;
+ totl += l;
+ mlens[m->gnum] = l;
+ nlist++;
+ if (!(m->flags & CMF_PACKED))
+ g->flags &= ~CGF_PACKED;
+ if (!(m->flags & CMF_ROWS))
+ g->flags &= ~CGF_ROWS;
+ }
} else
hidden = 1;
}
@@ -1508,7 +1510,7 @@
}
if (!onlyexpl) {
char **pp;
- int *ws, tlines, tline, tcols, maxlen, nth, width, glines;
+ int *ws, tlines, tcols, width, glines;
for (g = amatches; g; g = g->next) {
glines = 0;
@@ -1572,201 +1574,149 @@
ylens[i] = ztrlen(*pp) + add;
if (g->flags & CGF_ROWS) {
- int count, tcol, first, maxlines = 0, llines;
- int beg = columns / g->shortest, end = g->cols;
+ int nth, tcol, len;
- while (1) {
- tcols = (beg + end) >> 1;
-
- for (nth = first = maxlen = width = maxlines =
- llines = tcol = 0,
- count = g->dcount;
- count > 0; count--) {
- if (ylens[nth] > maxlen)
- maxlen = ylens[nth];
- nth += tcols;
- tlines++;
- if (nth >= g->dcount) {
- if ((width += maxlen) >= columns)
- break;
- ws[tcol++] = maxlen;
- maxlen = 0;
- nth = ++first;
- if (llines > maxlines)
- maxlines = llines;
- llines = 0;
- }
- }
- if (nth < yl) {
- ws[tcol++] = maxlen;
- width += maxlen;
- }
- if (!count && width <= columns &&
- (tcols <= 0 || beg == end))
- break;
-
- if (beg == end) {
- beg--;
- end--;
- } else if (width < columns) {
- if ((end = tcols) == beg - 1)
- end++;
- } else {
- if ((beg = tcols) - 1 == end)
- end++;
- }
- }
- if (tcols > g->cols)
- tlines = maxlines;
+ for (tcols = columns / (g->shortest + add);
+ tcols > g->cols;
+ tcols--) {
+
+ memset(ws, 0, tcols * sizeof(int));
+
+ for (width = nth = tcol = 0, tlines = 1;
+ width < columns && nth < g->dcount;
+ nth++, tcol++) {
+
+ m = *p;
+
+ if (tcol == tcols) {
+ tcol = 0;
+ tlines++;
+ }
+ len = ylens[nth];
+
+ if (len > ws[tcol]) {
+ width += len - ws[tcol];
+ ws[tcol] = len;
+ }
+ }
+ if (width < columns)
+ break;
+ }
} else {
- int beg = ((g->totl + columns) / columns);
- int end = g->lins;
+ int nth, tcol, tline, len;
- while (1) {
- tlines = (beg + end) >> 1;
-
- for (pp = g->ylist, nth = tline = width =
- maxlen = tcols = 0;
- *pp; pp++) {
- if (ylens[nth] > maxlen)
- maxlen = ylens[nth];
- if (++tline == tlines) {
- if ((width += maxlen) >= columns)
- break;
- ws[tcols++] = maxlen;
- maxlen = tline = 0;
- }
- nth++;
- }
- if (tline) {
- ws[tcols++] = maxlen;
- width += maxlen;
- }
- if (nth == yl && width <= columns &&
- (beg == end || tlines >= g->lins))
- break;
-
- if (beg == end) {
- beg++;
- end++;
- } else if (width < columns) {
- if ((end = tlines) == beg + 1)
- end--;
- } else {
- if ((beg = tlines) + 1 == end)
- end--;
- }
- }
- if (tlines > g->lins)
- tlines = g->lins;
+ for (tcols = columns / (g->shortest + add);
+ tcols > g->cols;
+ tcols--) {
+
+ if ((tlines = (g->dcount + tcols - 1) / tcols) <= 0)
+ tlines = 1;
+
+ memset(ws, 0, tcols * sizeof(int));
+
+ for (width = nth = tcol = tline = 0;
+ width < columns && nth < g->dcount;
+ nth++, tline++) {
+
+ m = *p;
+
+ if (tline == tlines) {
+ tcol++;
+ tline = 0;
+ }
+ if (tcol == tcols) {
+ tcol = 0;
+ tlines++;
+ }
+ len = ylens[nth];
+
+ if (len > ws[tcol]) {
+ width += len - ws[tcol];
+ ws[tcol] = len;
+ }
+ }
+ if (width < columns)
+ break;
+ }
}
}
} else if (g->width) {
if (g->flags & CGF_ROWS) {
- int addlen, count, tcol, maxlines = 0, llines, i;
- int beg = columns / g->shortest, end = g->cols;
- Cmatch *first;
-
- while (1) {
- tcols = (beg + end) >> 1;
-
- p = first = skipnolist(g->matches, showall);
- for (maxlen = width = maxlines = llines = tcol = 0,
- count = g->dcount;
- count > 0; count--) {
- m = *p;
- addlen = mlens[m->gnum] + add;
- if (addlen > maxlen)
- maxlen = addlen;
- for (i = tcols; i && *p; i--)
- p = skipnolist(p + 1, showall);
-
- llines++;
- if (!*p) {
- if (llines > maxlines)
- maxlines = llines;
- llines = 0;
-
- if ((width += maxlen) >= columns)
- break;
- ws[tcol++] = maxlen;
- maxlen = 0;
+ int nth, tcol, len;
- p = first = skipnolist(first + 1, showall);
- }
- }
- if (tlines) {
- ws[tcol++] = maxlen;
- width += maxlen;
- }
- if (!count && width <= columns &&
- (tcols <= 0 || beg == end))
- break;
-
- if (beg == end) {
- beg--;
- end--;
- } else if (width < columns) {
- if ((end = tcols) == beg - 1)
- end++;
- } else {
- if ((beg = tcols) - 1 == end)
- end++;
- }
- }
- if (tcols > g->cols)
- tlines = maxlines;
+ for (tcols = columns / (g->shortest + add);
+ tcols > g->cols;
+ tcols--) {
+
+ memset(ws, 0, tcols * sizeof(int));
+
+ for (width = nth = tcol = 0, tlines = 1,
+ p = skipnolist(g->matches, showall);
+ *p && width < columns && nth < g->dcount;
+ nth++, p = skipnolist(p + 1, showall), tcol++) {
+
+ m = *p;
+
+ if (tcol == tcols) {
+ tcol = 0;
+ tlines++;
+ }
+ len = (mlens[m->gnum] +
+ (tcol == tcols - 1 ? 0 : add));
+
+ if (len > ws[tcol]) {
+ width += len - ws[tcol];
+ ws[tcol] = len;
+ }
+ }
+ if (width < columns)
+ break;
+ }
} else {
- int addlen;
- int smask = ((showall ? 0 : (CMF_NOLIST | CMF_MULT)) |
- CMF_HIDE);
- int beg = ((g->totl + columns) / columns);
- int end = g->lins;
-
- while (1) {
- tlines = (beg + end) >> 1;
-
- for (p = g->matches, nth = tline = width =
- maxlen = tcols = 0;
- (m = *p); p++) {
- if (!(m->flags &
- (m->disp ? (CMF_DISPLINE | CMF_HIDE) :
- smask))) {
- addlen = mlens[m->gnum] + add;
- if (addlen > maxlen)
- maxlen = addlen;
- if (++tline == tlines) {
- if ((width += maxlen) >= columns)
- break;
- ws[tcols++] = maxlen;
- maxlen = tline = 0;
- }
- nth++;
- }
- }
- if (tline) {
- ws[tcols++] = maxlen;
- width += maxlen;
- }
- if (nth == g->dcount && width <= columns &&
- (beg == end || tlines >= g->lins))
- break;
-
- if (beg == end) {
- beg++;
- end++;
- } else if (width < columns) {
- if ((end = tlines) == beg + 1)
- end--;
- } else {
- if ((beg = tlines) + 1 == end)
- end--;
- }
- }
- if (tlines > g->lins)
- tlines = g->lins;
+ int nth, tcol, tline, len;
+
+ for (tcols = columns / (g->shortest + add);
+ tcols > g->cols;
+ tcols--) {
+
+ if ((tlines = (g->dcount + tcols - 1) / tcols) <= 0)
+ tlines = 1;
+
+ memset(ws, 0, tcols * sizeof(int));
+
+ for (width = nth = tcol = tline = 0,
+ p = skipnolist(g->matches, showall);
+ *p && width < columns && nth < g->dcount;
+ nth++, p = skipnolist(p + 1, showall), tline++) {
+
+ m = *p;
+
+ if (tline == tlines) {
+ tcol++;
+ tline = 0;
+ }
+ if (tcol == tcols) {
+ tcol = 0;
+ tlines++;
+ }
+ len = (mlens[m->gnum] +
+ (tcol == tcols - 1 ? 0 : add));
+
+ if (len > ws[tcol]) {
+ width += len - ws[tcol];
+ ws[tcol] = len;
+ }
+ }
+ if (width < columns) {
+ if (++tcol < tcols)
+ tcols = tcol;
+ break;
+ }
+ }
}
}
+ if (tcols <= g->cols)
+ tlines = g->lins;
if (tlines == g->lins) {
zfree(ws, columns * sizeof(int));
g->widths = NULL;
prev parent reply other threads:[~2003-02-05 2:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-04 1:12 Greg Klanderman
2003-02-04 10:05 ` Bart Schaefer
2003-02-05 2:08 ` Greg Klanderman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15936.29191.196889.6099@phl.itasoftware.com \
--to=gak@klanderman.net \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).