From 0960d813f8ac6f8912bdcae146fe3d6994f0c98f Mon Sep 17 00:00:00 2001 From: Jan Cybulski Date: Fri, 17 Oct 2014 08:59:24 +0200 Subject: [PATCH] ls: Fix identation of number of blocks and inodes Identation was not properly done, which was especially seen with -l option. Change-Id: I681f6f0b8cf105f7f88f0dfc7779718895f9521c Signed-off-by: Jan Cybulski --- toys/posix/ls.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/toys/posix/ls.c b/toys/posix/ls.c index aba56e6..ef64d19 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c @@ -331,6 +331,8 @@ static void listfiles(int dirfd, struct dirtree *indir) colsizes[c] = *len; if (totlen > TT.screen_width) break; } + for (width=0; width<7; width++) + if (len[width] > totals[width]) totals[width] = len[width]; } // If it fit, stop here if (ul == dtlen) break; @@ -341,7 +343,7 @@ static void listfiles(int dirfd, struct dirtree *indir) for (ul = 0; ul totals[width]) totals[width] = len[width]; blocks += sort[ul]->st.st_blocks; } @@ -379,8 +381,8 @@ static void listfiles(int dirfd, struct dirtree *indir) } width += *len; - if (flags & FLAG_i) xprintf("%*lu ", len[1], (unsigned long)st->st_ino); - if (flags & FLAG_s) xprintf("%*lu ", len[6], (unsigned long)st->st_blocks); + if (flags & FLAG_i) xprintf("%*lu ", totals[1], (unsigned long)st->st_ino); + if (flags & FLAG_s) xprintf("%*lu ", totals[6], (unsigned long)st->st_blocks); if (flags & (FLAG_l|FLAG_o|FLAG_n|FLAG_g)) { struct tm *tm; -- 2.7.4