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:
cperciva 2004-01-22 04:33:00 +00:00
parent 9c74fea4de
commit 67d46f9377

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);