diff options
author | Rob Landley <rob@landley.net> | 2014-04-16 08:54:19 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-04-16 08:54:19 -0500 |
commit | 6c64f5f186d26d4c95d408979d33831935e026f1 (patch) | |
tree | b08b59e7f980f3ab74d856923175dae0d4cd87c2 /toys/posix/du.c | |
parent | 76e1cb3ada7fb12f38e248a08c2deedc5c9ce888 (diff) | |
download | toybox-6c64f5f186d26d4c95d408979d33831935e026f1.tar.gz |
Revert lots of half-finished local debris I didn't mean to check in with Isaac's roadmap update.
Mercurial's "import" command is still broken, committing local tree changes to files that weren't even touched by the patch because the hg developers inisist, when I point out how stupid it is, that they meant to do that. (hg record can do hunks, but import can't even track _files_.)
Diffstat (limited to 'toys/posix/du.c')
-rw-r--r-- | toys/posix/du.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/toys/posix/du.c b/toys/posix/du.c index 64ba0517..96922bca 100644 --- a/toys/posix/du.c +++ b/toys/posix/du.c @@ -54,8 +54,18 @@ static void print(long long size, struct dirtree *node) if (TT.maxdepth && TT.depth > TT.maxdepth) return; - if (toys.optflags & FLAG_h) printf("%s", human_readable(size)); - else { + 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]); + } else { int bits = 10; if (toys.optflags & FLAG_K) bits = 9; |