From: Francois Fleuret Date: Thu, 18 Mar 2010 07:01:43 +0000 (+0100) Subject: Now take the -c option into account. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=79b0720406d830cfa9bf0a522e2da73ce173b0f8;p=dus.git Now take the -c option into account. --- 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); }