1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-08 12:01:21 +02:00

zsh-workers/10176

This commit is contained in:
Tanaka Akira 2000-03-23 04:05:43 +00:00
parent a4881858d8
commit 7ab508430c
3 changed files with 85 additions and 23 deletions

View file

@ -1288,9 +1288,11 @@ calclist(int showall)
} }
} }
if (!onlyexpl) { if (!onlyexpl) {
for (g = amatches; g; g = g->next) {
char **pp; char **pp;
int glines = 0; int *ws, tlines, tline, tcols, maxlen, nth, width, glines;
for (g = amatches; g; g = g->next) {
glines = 0;
zfree(g->widths, 0); zfree(g->widths, 0);
g->widths = NULL; g->widths = NULL;
@ -1332,11 +1334,6 @@ calclist(int showall)
g->lins = glines; g->lins = glines;
nlines += glines; nlines += glines;
} }
}
if (!onlyexpl) {
char **pp;
int *ws, tlines, tline, tcols, maxlen, nth, width;
for (g = amatches; g; g = g->next) { for (g = amatches; g; g = g->next) {
if (!(g->flags & CGF_PACKED)) if (!(g->flags & CGF_PACKED))
continue; continue;
@ -1357,9 +1354,11 @@ calclist(int showall)
if (g->flags & CGF_ROWS) { if (g->flags & CGF_ROWS) {
int count, tcol, first, maxlines = 0, llines; 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 = for (nth = first = maxlen = width = maxlines =
llines = tcol = 0, llines = tcol = 0,
count = g->dcount; count = g->dcount;
@ -1383,17 +1382,33 @@ calclist(int showall)
ws[tcol++] = maxlen; ws[tcol++] = maxlen;
width += maxlen; width += maxlen;
} }
if (!count && width < columns) if (!count && width < columns &&
(tcols <= 0 || beg == end))
break; 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) if (tcols > g->cols)
tlines = maxlines; tlines = maxlines;
} else { } else {
for (tlines = ((g->totl + columns) / columns); int beg = ((g->totl + columns) / columns);
tlines < g->lins; tlines++) { int end = g->lins;
while (1) {
tlines = (beg + end) >> 1;
for (pp = g->ylist, nth = tline = width = for (pp = g->ylist, nth = tline = width =
maxlen = tcols = 0; maxlen = tcols = 0;
*pp; nth++, pp++) { *pp; pp++) {
if (ylens[nth] > maxlen) if (ylens[nth] > maxlen)
maxlen = ylens[nth]; maxlen = ylens[nth];
if (++tline == tlines) { if (++tline == tlines) {
@ -1402,23 +1417,40 @@ calclist(int showall)
ws[tcols++] = maxlen; ws[tcols++] = maxlen;
maxlen = tline = 0; maxlen = tline = 0;
} }
nth++;
} }
if (tline) { if (tline) {
ws[tcols++] = maxlen; ws[tcols++] = maxlen;
width += maxlen; width += maxlen;
} }
if (nth == yl && width < columns) if (nth == yl && width < columns &&
(beg == end || tlines >= g->lins))
break; 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) { } else if (g->width) {
if (g->flags & CGF_ROWS) { if (g->flags & CGF_ROWS) {
int addlen, count, tcol, maxlines = 0, llines, i; int addlen, count, tcol, maxlines = 0, llines, i;
int beg = columns / g->shortest, end = g->cols;
Cmatch *first; Cmatch *first;
for (tcols = columns / g->shortest; tcols > g->cols; while (1) {
tcols--) { tcols = (beg + end) >> 1;
p = first = skipnolist(g->matches, showall); p = first = skipnolist(g->matches, showall);
for (maxlen = width = maxlines = llines = tcol = 0, for (maxlen = width = maxlines = llines = tcol = 0,
count = g->dcount; count = g->dcount;
@ -1448,8 +1480,20 @@ calclist(int showall)
ws[tcol++] = maxlen; ws[tcol++] = maxlen;
width += maxlen; width += maxlen;
} }
if (!count && width < columns) if (!count && width < columns &&
(tcols <= 0 || beg == end))
break; 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) if (tcols > g->cols)
tlines = maxlines; tlines = maxlines;
@ -1457,12 +1501,15 @@ calclist(int showall)
int addlen; int addlen;
int smask = ((showall ? 0 : (CMF_NOLIST | CMF_MULT)) | int smask = ((showall ? 0 : (CMF_NOLIST | CMF_MULT)) |
CMF_HIDE); 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 = for (p = g->matches, nth = tline = width =
maxlen = tcols = 0; maxlen = tcols = 0;
(m = *p); p++, nth++) { (m = *p); p++) {
if (!(m->flags & if (!(m->flags &
(m->disp ? (CMF_DISPLINE | CMF_HIDE) : (m->disp ? (CMF_DISPLINE | CMF_HIDE) :
smask))) { smask))) {
@ -1475,16 +1522,31 @@ calclist(int showall)
ws[tcols++] = maxlen; ws[tcols++] = maxlen;
maxlen = tline = 0; maxlen = tline = 0;
} }
nth++;
} }
} }
if (tline) { if (tline) {
ws[tcols++] = maxlen; ws[tcols++] = maxlen;
width += maxlen; width += maxlen;
} }
if (nth == g->dcount && width < columns) if (nth == g->dcount && width < columns &&
(beg == end || tlines >= g->lins))
break; 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) { if (tlines == g->lins) {
zfree(ws, columns * sizeof(int)); zfree(ws, columns * sizeof(int));

View file

@ -900,7 +900,7 @@ int
source(char *s) source(char *s)
{ {
Eprog prog; Eprog prog;
int tempfd, fd, cj, oldlineno; int tempfd = -1, fd, cj, oldlineno;
int oldshst, osubsh, oloops; int oldshst, osubsh, oloops;
FILE *obshin; FILE *obshin;
char *old_scriptname = scriptname, *us; char *old_scriptname = scriptname, *us;

View file

@ -2596,7 +2596,7 @@ build_cur_dump(char *nam, char *dump, char **names, int match, int map, int flag
{ {
int dfd, hlen, tlen; int dfd, hlen, tlen;
LinkList progs, lnames; LinkList progs, lnames;
Shfunc shf; Shfunc shf = NULL;
if (!strsfx(FD_EXT, dump)) if (!strsfx(FD_EXT, dump))
dump = dyncat(dump, FD_EXT); dump = dyncat(dump, FD_EXT);