diff options
author | Rob Landley <rob@landley.net> | 2014-05-06 06:31:28 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-05-06 06:31:28 -0500 |
commit | 48c172ba589cfd848624b51f6f748b56bc217775 (patch) | |
tree | 36439338e020b5fc3dad76c067117a8182624246 /toys/posix/du.c | |
parent | 30e28cf7e166cf54b3a2a4fea5e6e134b5968812 (diff) | |
download | toybox-48c172ba589cfd848624b51f6f748b56bc217775.tar.gz |
Switch human_readable() to just outputing decimal kilo/mega/gigabytes, make du use it, move it from lib/pending.c to lib.c.
Diffstat (limited to 'toys/posix/du.c')
-rw-r--r-- | toys/posix/du.c | 12 |
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; |