X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=dus.git;a=blobdiff_plain;f=dus.c;h=d361712c3660110a1d97753aa68446ccfb40a12a;hp=97883a6df462bf519c7e83ffe4bb789ca4884bdc;hb=d98a016c96a3c0593838532465178b1ae82efabc;hpb=7feedc1bca1d49995cac360e0a98049d07a90d6c diff --git a/dus.c b/dus.c index 97883a6..d361712 100644 --- a/dus.c +++ b/dus.c @@ -242,7 +242,7 @@ void raw_print(char *buffer, char *filename, size_sum_t size) { *(b++) = ' '; - sprintf(b, " %s\n", filename); + sprintf(b, "%s\n", filename); } void fancy_print(char *buffer, char *filename, size_sum_t size) { @@ -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); }