comparison toys/posix/du.c @ 1261:9e105bab92e5 draft

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_.)
author Rob Landley <rob@landley.net>
date Wed, 16 Apr 2014 08:54:19 -0500
parents 6ca31490f581
children d48bdc1cb017
comparison
equal deleted inserted replaced
1260:0ce03bb85ebd 1261:9e105bab92e5
52 { 52 {
53 char *name = "total"; 53 char *name = "total";
54 54
55 if (TT.maxdepth && TT.depth > TT.maxdepth) return; 55 if (TT.maxdepth && TT.depth > TT.maxdepth) return;
56 56
57 if (toys.optflags & FLAG_h) printf("%s", human_readable(size)); 57 if (toys.optflags & FLAG_h) {
58 else { 58 char buf[32];
59 int index, sz;
60
61 for (index = 0; 1024 < size>>(10*index); index++);
62 sz = size>>(10*index);
63 if (sz < 10) {
64 sprintf(buf, "%llu", size>>(10*(index-1)));
65 printf("%c.%c", buf[0], buf[1]);
66 } else printf("%d", sz);
67 if (index) printf("%c", " KMGTPE"[index]);
68 } else {
59 int bits = 10; 69 int bits = 10;
60 70
61 if (toys.optflags & FLAG_K) bits = 9; 71 if (toys.optflags & FLAG_K) bits = 9;
62 else if (toys.optflags & FLAG_m) bits = 20; 72 else if (toys.optflags & FLAG_m) bits = 20;
63 73