From: Francois Fleuret Date: Tue, 16 Mar 2010 18:22:02 +0000 (+0100) Subject: Remove the buggy "..." when files are too small to be listed. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=8e09f294c0aeeaca6658694b20246989d28c591d;p=dus.git Remove the buggy "..." when files are too small to be listed. --- 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) {