X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=dus.git;a=blobdiff_plain;f=dus.c;h=347ecaefbd270c1d77e699300740ef7ff544b2aa;hp=97883a6df462bf519c7e83ffe4bb789ca4884bdc;hb=79b0720406d830cfa9bf0a522e2da73ce173b0f8;hpb=7feedc1bca1d49995cac360e0a98049d07a90d6c 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); }