X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=dus.git;a=blobdiff_plain;f=dus.c;h=083f96edeb27d833524f71a253bd6c90e7172246;hp=f1be9f2fb4d5ae9369ce7a4e4895177ac6c11192;hb=8e09f294c0aeeaca6658694b20246989d28c591d;hpb=8f34c2a3b6f0f23f9125f75d35955df3b01d8140 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) {