diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-03-06 17:53:11 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-03-06 17:53:11 +0100 |
| commit | ea351b97428f7dc921d5431ccac366201754fcef (patch) | |
| tree | ae1155eace4dc3f56fdad2ce146c549a76adb07f /coreutils | |
| parent | 7849ccb61c376e4704ce1c3e5a0d12fd7d743200 (diff) | |
| download | busybox-w32-ea351b97428f7dc921d5431ccac366201754fcef.tar.gz busybox-w32-ea351b97428f7dc921d5431ccac366201754fcef.tar.bz2 busybox-w32-ea351b97428f7dc921d5431ccac366201754fcef.zip | |
ls: fix columnar output. Closes 8731
In coreutils/ls.c, 1.19 introduced commit
2f7d9e8903029b1b5e51a15f9cb0dcb6ca17c3ac, removing the variable tabstops and
hard coding the column separation to 2 characters, but was not done correctly.
The column_width assumes a gap of 1 character, so the computed number of
columns exceeds the terminal width when many small files are encountered.
A minor problem but surprisingly annoying.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/ls.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index c48498858..20bd61860 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
| @@ -668,7 +668,7 @@ static void display_files(struct dnode **dn, unsigned nfiles) | |||
| 668 | if (column_width < len) | 668 | if (column_width < len) |
| 669 | column_width = len; | 669 | column_width = len; |
| 670 | } | 670 | } |
| 671 | column_width += 1 + | 671 | column_width += 2 + |
| 672 | IF_SELINUX( ((G.all_fmt & LIST_CONTEXT) ? 33 : 0) + ) | 672 | IF_SELINUX( ((G.all_fmt & LIST_CONTEXT) ? 33 : 0) + ) |
| 673 | ((G.all_fmt & LIST_INO) ? 8 : 0) + | 673 | ((G.all_fmt & LIST_INO) ? 8 : 0) + |
| 674 | ((G.all_fmt & LIST_BLOCKS) ? 5 : 0); | 674 | ((G.all_fmt & LIST_BLOCKS) ? 5 : 0); |
| @@ -696,8 +696,8 @@ static void display_files(struct dnode **dn, unsigned nfiles) | |||
| 696 | if (i < nfiles) { | 696 | if (i < nfiles) { |
| 697 | if (column > 0) { | 697 | if (column > 0) { |
| 698 | nexttab -= column; | 698 | nexttab -= column; |
| 699 | printf("%*s ", nexttab, ""); | 699 | printf("%*s", nexttab, ""); |
| 700 | column += nexttab + 1; | 700 | column += nexttab; |
| 701 | } | 701 | } |
| 702 | nexttab = column + column_width; | 702 | nexttab = column + column_width; |
| 703 | column += display_single(dn[i]); | 703 | column += display_single(dn[i]); |
