Fix alignment of size field in ls -lh -- the width was being computed

from log[10](largest file size), but when outputting in human-friendly
format the width is always at most 4. (eg. "123K", " 12K", "1.2K".)

PR: bin/59320
Approved by: rwatson (mentor)
This commit is contained in:
Colin Percival 2004-01-22 04:33:00 +00:00
parent 54ca359425
commit d3b68bf14c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=124825

View File

@ -624,9 +624,9 @@ printsize(size_t width, off_t bytes)
unit = unit_adjust(&dbytes);
if (dbytes == 0)
(void)printf("%*s ", (u_int)width, "0B");
(void)printf("%*s ", 4, "0B");
else
(void)printf("%*.*f%c ", (u_int)width - 1,
(void)printf("%*.*f%c ", 3,
dbytes > 10 ? 0 : 1, dbytes, "BKMGTPE"[unit]);
} else
(void)printf("%*jd ", (u_int)width, bytes);