summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ls.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ls.c b/src/ls.c
index 0c9dc78db..ef372553f 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1979,7 +1979,11 @@ decode_switches (int argc, char **argv)
}
}
- max_idx = MAX (1, line_length / MIN_COLUMN_WIDTH);
+ /* Determine the max possible number of display columns. */
+ max_idx = line_length / MIN_COLUMN_WIDTH;
+ /* Account for first display column not having a separator,
+ or line_lengths shorter than MIN_COLUMN_WIDTH. */
+ max_idx += line_length % MIN_COLUMN_WIDTH != 0;
filename_quoting_options = clone_quoting_options (NULL);
if (get_quoting_style (filename_quoting_options) == escape_quoting_style)