From 8e09f294c0aeeaca6658694b20246989d28c591d Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Tue, 16 Mar 2010 19:22:02 +0100 Subject: [PATCH] Remove the buggy "..." when files are too small to be listed. --- dus.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/dus.c b/dus.c index f1be9f2..083f96e 100644 --- a/dus.c +++ b/dus.c @@ -277,14 +277,18 @@ void print_sorted(struct file_with_size *root, int width, int height) { nb_nodes = 0; for(node = root; node; node = node->next) { - nb_nodes++; + if(size_min < 0 || node->size >= size_min) { + nb_nodes++; + } } nodes = safe_malloc(nb_nodes * sizeof(struct file_with_size *)); n = 0; for(node = root; node; node = node->next) { - nodes[n++] = node; + if(size_min < 0 || node->size >= size_min) { + nodes[n++] = node; + } } qsort(nodes, nb_nodes, sizeof(struct file_with_size *), compare_files); @@ -311,17 +315,15 @@ void print_sorted(struct file_with_size *root, int width, int height) { } for(n = first; n < last; n++) { - if(size_min < 0 || nodes[n]->size >= size_min) { - if(fancy_size_display) { - fancy_print(line, nodes[n]->filename, nodes[n]->size); - } else { - raw_print(line, nodes[n]->filename, nodes[n]->size); - } - if(width >= 0 && width < BUFFER_SIZE) { - line[width] = '\0'; - } - printf(line); + if(fancy_size_display) { + fancy_print(line, nodes[n]->filename, nodes[n]->size); + } else { + raw_print(line, nodes[n]->filename, nodes[n]->size); + } + if(width >= 0 && width < BUFFER_SIZE) { + line[width] = '\0'; } + printf(line); } if(height >= 0 && nb_nodes > height && show_top && !forced_height) { -- 2.20.1