diff options
Diffstat (limited to 'sftp-int.c')
-rw-r--r-- | sftp-int.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sftp-int.c b/sftp-int.c index a9423fe69..3ee57515d 100644 --- a/sftp-int.c +++ b/sftp-int.c | |||
@@ -25,7 +25,7 @@ | |||
25 | /* XXX: recursive operations */ | 25 | /* XXX: recursive operations */ |
26 | 26 | ||
27 | #include "includes.h" | 27 | #include "includes.h" |
28 | RCSID("$OpenBSD: sftp-int.c,v 1.66 2004/01/13 09:25:05 djm Exp $"); | 28 | RCSID("$OpenBSD: sftp-int.c,v 1.67 2004/01/23 17:57:48 mouring Exp $"); |
29 | 29 | ||
30 | #include "buffer.h" | 30 | #include "buffer.h" |
31 | #include "xmalloc.h" | 31 | #include "xmalloc.h" |
@@ -595,17 +595,24 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag) | |||
595 | if (!(lflag & SHORT_VIEW)) { | 595 | if (!(lflag & SHORT_VIEW)) { |
596 | int m = 0, width = 80; | 596 | int m = 0, width = 80; |
597 | struct winsize ws; | 597 | struct winsize ws; |
598 | char *tmp; | ||
598 | 599 | ||
599 | /* Count entries for sort and find longest filename */ | 600 | /* Count entries for sort and find longest filename */ |
600 | for (n = 0; d[n] != NULL; n++) | 601 | for (n = 0; d[n] != NULL; n++) |
601 | m = MAX(m, strlen(d[n]->filename)); | 602 | m = MAX(m, strlen(d[n]->filename)); |
602 | 603 | ||
604 | /* Add any subpath that also needs to be counted */ | ||
605 | tmp = path_strip(path, strip_path); | ||
606 | m += strlen(tmp); | ||
607 | xfree(tmp); | ||
608 | |||
603 | if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) | 609 | if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) |
604 | width = ws.ws_col; | 610 | width = ws.ws_col; |
605 | 611 | ||
606 | columns = width / (m + 2); | 612 | columns = width / (m + 2); |
607 | columns = MAX(columns, 1); | 613 | columns = MAX(columns, 1); |
608 | colspace = width / columns; | 614 | colspace = width / columns; |
615 | colspace = MIN(colspace, width); | ||
609 | } | 616 | } |
610 | 617 | ||
611 | qsort(d, n, sizeof(*d), sdirent_comp); | 618 | qsort(d, n, sizeof(*d), sdirent_comp); |