From 79b0720406d830cfa9bf0a522e2da73ce173b0f8 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Thu, 18 Mar 2010 08:01:43 +0100 Subject: [PATCH] Now take the -c option into account. --- dus.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dus.c b/dus.c index 97883a6..347ecae 100644 --- a/dus.c +++ b/dus.c @@ -300,6 +300,10 @@ void print_sorted(struct entry_node *root, int width, int height) { height = forced_height; } + if(forced_width) { + width = forced_width; + } + if(height >= 0 && nb_nodes > height && !show_top && !forced_height) { printf("...\n"); } @@ -320,8 +324,9 @@ void print_sorted(struct entry_node *root, int width, int height) { } else { raw_print(line, nodes[n]->name, nodes[n]->size); } - if(width >= 0 && width < BUFFER_SIZE) { - line[width] = '\0'; + if(width >= 1 && width + 1 < BUFFER_SIZE && line[width]) { + line[width] = '\n'; + line[width + 1] = '\0'; } printf(line); } -- 2.20.1