version 1.66, 2004/01/13 09:25:05 |
version 1.67, 2004/01/23 17:57:48 |
|
|
if (!(lflag & SHORT_VIEW)) { |
if (!(lflag & SHORT_VIEW)) { |
int m = 0, width = 80; |
int m = 0, width = 80; |
struct winsize ws; |
struct winsize ws; |
|
char *tmp; |
|
|
/* Count entries for sort and find longest filename */ |
/* Count entries for sort and find longest filename */ |
for (n = 0; d[n] != NULL; n++) |
for (n = 0; d[n] != NULL; n++) |
m = MAX(m, strlen(d[n]->filename)); |
m = MAX(m, strlen(d[n]->filename)); |
|
|
|
/* Add any subpath that also needs to be counted */ |
|
tmp = path_strip(path, strip_path); |
|
m += strlen(tmp); |
|
xfree(tmp); |
|
|
if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) |
if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) |
width = ws.ws_col; |
width = ws.ws_col; |
|
|
columns = width / (m + 2); |
columns = width / (m + 2); |
columns = MAX(columns, 1); |
columns = MAX(columns, 1); |
colspace = width / columns; |
colspace = width / columns; |
|
colspace = MIN(colspace, width); |
} |
} |
|
|
qsort(d, n, sizeof(*d), sdirent_comp); |
qsort(d, n, sizeof(*d), sdirent_comp); |