mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-01 21:51:40 +02:00
zsh-workers/10176
This commit is contained in:
parent
a4881858d8
commit
7ab508430c
3 changed files with 85 additions and 23 deletions
|
@ -1288,9 +1288,11 @@ calclist(int showall)
|
|||
}
|
||||
}
|
||||
if (!onlyexpl) {
|
||||
char **pp;
|
||||
int *ws, tlines, tline, tcols, maxlen, nth, width, glines;
|
||||
|
||||
for (g = amatches; g; g = g->next) {
|
||||
char **pp;
|
||||
int glines = 0;
|
||||
glines = 0;
|
||||
|
||||
zfree(g->widths, 0);
|
||||
g->widths = NULL;
|
||||
|
@ -1332,11 +1334,6 @@ calclist(int showall)
|
|||
g->lins = glines;
|
||||
nlines += glines;
|
||||
}
|
||||
}
|
||||
if (!onlyexpl) {
|
||||
char **pp;
|
||||
int *ws, tlines, tline, tcols, maxlen, nth, width;
|
||||
|
||||
for (g = amatches; g; g = g->next) {
|
||||
if (!(g->flags & CGF_PACKED))
|
||||
continue;
|
||||
|
@ -1357,9 +1354,11 @@ calclist(int showall)
|
|||
|
||||
if (g->flags & CGF_ROWS) {
|
||||
int count, tcol, first, maxlines = 0, llines;
|
||||
int beg = columns / g->shortest, end = g->cols;
|
||||
|
||||
while (1) {
|
||||
tcols = (beg + end) >> 1;
|
||||
|
||||
for (tcols = columns / g->shortest; tcols > g->cols;
|
||||
tcols--) {
|
||||
for (nth = first = maxlen = width = maxlines =
|
||||
llines = tcol = 0,
|
||||
count = g->dcount;
|
||||
|
@ -1383,17 +1382,33 @@ calclist(int showall)
|
|||
ws[tcol++] = maxlen;
|
||||
width += maxlen;
|
||||
}
|
||||
if (!count && width < columns)
|
||||
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;
|
||||
} else {
|
||||
for (tlines = ((g->totl + columns) / columns);
|
||||
tlines < g->lins; tlines++) {
|
||||
int beg = ((g->totl + columns) / columns);
|
||||
int end = g->lins;
|
||||
|
||||
while (1) {
|
||||
tlines = (beg + end) >> 1;
|
||||
|
||||
for (pp = g->ylist, nth = tline = width =
|
||||
maxlen = tcols = 0;
|
||||
*pp; nth++, pp++) {
|
||||
*pp; pp++) {
|
||||
if (ylens[nth] > maxlen)
|
||||
maxlen = ylens[nth];
|
||||
if (++tline == tlines) {
|
||||
|
@ -1402,23 +1417,40 @@ calclist(int showall)
|
|||
ws[tcols++] = maxlen;
|
||||
maxlen = tline = 0;
|
||||
}
|
||||
nth++;
|
||||
}
|
||||
if (tline) {
|
||||
ws[tcols++] = maxlen;
|
||||
width += maxlen;
|
||||
}
|
||||
if (nth == yl && width < columns)
|
||||
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;
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
|
||||
for (tcols = columns / g->shortest; tcols > g->cols;
|
||||
tcols--) {
|
||||
while (1) {
|
||||
tcols = (beg + end) >> 1;
|
||||
|
||||
p = first = skipnolist(g->matches, showall);
|
||||
for (maxlen = width = maxlines = llines = tcol = 0,
|
||||
count = g->dcount;
|
||||
|
@ -1448,8 +1480,20 @@ calclist(int showall)
|
|||
ws[tcol++] = maxlen;
|
||||
width += maxlen;
|
||||
}
|
||||
if (!count && width < columns)
|
||||
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;
|
||||
|
@ -1457,12 +1501,15 @@ calclist(int showall)
|
|||
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 (tlines = ((g->totl + columns) / columns);
|
||||
tlines < g->lins; tlines++) {
|
||||
for (p = g->matches, nth = tline = width =
|
||||
maxlen = tcols = 0;
|
||||
(m = *p); p++, nth++) {
|
||||
(m = *p); p++) {
|
||||
if (!(m->flags &
|
||||
(m->disp ? (CMF_DISPLINE | CMF_HIDE) :
|
||||
smask))) {
|
||||
|
@ -1475,15 +1522,30 @@ calclist(int showall)
|
|||
ws[tcols++] = maxlen;
|
||||
maxlen = tline = 0;
|
||||
}
|
||||
nth++;
|
||||
}
|
||||
}
|
||||
if (tline) {
|
||||
ws[tcols++] = maxlen;
|
||||
width += maxlen;
|
||||
}
|
||||
if (nth == g->dcount && width < columns)
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (tlines == g->lins) {
|
||||
|
|
|
@ -900,7 +900,7 @@ int
|
|||
source(char *s)
|
||||
{
|
||||
Eprog prog;
|
||||
int tempfd, fd, cj, oldlineno;
|
||||
int tempfd = -1, fd, cj, oldlineno;
|
||||
int oldshst, osubsh, oloops;
|
||||
FILE *obshin;
|
||||
char *old_scriptname = scriptname, *us;
|
||||
|
|
|
@ -2596,7 +2596,7 @@ build_cur_dump(char *nam, char *dump, char **names, int match, int map, int flag
|
|||
{
|
||||
int dfd, hlen, tlen;
|
||||
LinkList progs, lnames;
|
||||
Shfunc shf;
|
||||
Shfunc shf = NULL;
|
||||
|
||||
if (!strsfx(FD_EXT, dump))
|
||||
dump = dyncat(dump, FD_EXT);
|
||||
|
|
Loading…
Reference in a new issue