mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
ls: fix too few display columns edge case
In the edge case where the right most column would consist of only files taking 1 or 2 cells, we accounted for 3 cells, which would result in using 1 column too few. This should have been part of commit v8.24-59-ge71be1292 * src/ls.c (init_column_info): Don't account for separator in the the final column. * tests/ls/w-option.sh: Add a test case.
This commit is contained in:
1 parent
dce828c3d6
commit
13b8c11275
2 files changed
+22
-4
No files matched your search
@@ -993,8 +993,8 @@ static struct column_info *column_info;
|
||||
/* Maximum number of columns ever possible for this display. */
|
||||
static size_t max_idx;
|
||||
|
||||
/* The minimum width of a column is 3: 1 character for the name and 2
|
||||
for the separating white space. */
|
||||
/* The minimum width of a non-final column is 3: 1 character for the name
|
||||
and 2 for the separating white space. The final column is not padded. */
|
||||
enum { MIN_COLUMN_WIDTH = 3 };
|
||||
|
||||
|
||||
@@ -5276,9 +5276,10 @@ init_column_info (idx_t max_cols)
|
||||
for (idx_t i = 0; i < max_cols; ++i)
|
||||
{
|
||||
column_info[i].valid_len = true;
|
||||
column_info[i].line_len = (i + 1) * MIN_COLUMN_WIDTH;
|
||||
for (idx_t j = 0; j <= i; ++j)
|
||||
column_info[i].line_len = i * MIN_COLUMN_WIDTH + 1;
|
||||
for (idx_t j = 0; j < i; ++j)
|
||||
column_info[i].col_arr[j] = MIN_COLUMN_WIDTH;
|
||||
column_info[i].col_arr[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,4 +45,21 @@ TERM=xterm ls -w0 -x --color=always || fail=1
|
||||
ls -w4 -x -T0 a b > out || fail=1
|
||||
compare exp out || fail=1
|
||||
|
||||
# coreutils <= 9.11 could display 1 column too few
|
||||
touch aa c || framework_failure_
|
||||
cat <<\EOF > exp || framework_failure_
|
||||
aa b
|
||||
c
|
||||
EOF
|
||||
ls -w6 -x -T0 aa b c > out || fail=1
|
||||
compare exp out || fail=1
|
||||
|
||||
# coreutils <= 9.11 could display 1 column too few
|
||||
cat <<\EOF > exp || framework_failure_
|
||||
aa c
|
||||
b
|
||||
EOF
|
||||
ls -w6 -C -T0 aa b c > out || fail=1
|
||||
compare exp out || fail=1
|
||||
|
||||
Exit $fail
|
||||
Reference in new issue
Block a user