aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/du.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix/du.c')
-rw-r--r--toys/posix/du.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/toys/posix/du.c b/toys/posix/du.c
index 96922bca..2bfa7e41 100644
--- a/toys/posix/du.c
+++ b/toys/posix/du.c
@@ -55,16 +55,8 @@ static void print(long long size, struct dirtree *node)
if (TT.maxdepth && TT.depth > TT.maxdepth) return;
if (toys.optflags & FLAG_h) {
- char buf[32];
- int index, sz;
-
- for (index = 0; 1024 < size>>(10*index); index++);
- sz = size>>(10*index);
- if (sz < 10) {
- sprintf(buf, "%llu", size>>(10*(index-1)));
- printf("%c.%c", buf[0], buf[1]);
- } else printf("%d", sz);
- if (index) printf("%c", " KMGTPE"[index]);
+ human_readable(toybuf, size);
+ printf("%s", toybuf);
} else {
int bits = 10;