diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-08-30T14·18+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2018-08-30T14·22+0200 |
commit | 99828245f8f03a8b3b54a04f67e6df31235838f4 (patch) | |
tree | 1762ed86eb981f4b2d0ee1eeb1966eec0a5a3304 /src/nix | |
parent | c908df881f105d6a1004ae6a0e39da2d0149f3e9 (diff) |
printSize() fixes
Fix a 32-bit overflow that resulted in negative numbers being printed; use fmt() instead of boost::format(); change -H to -h for consistency with 'ls' and 'du'; make the columns narrower (since they can't be bigger than 1024.0).
Diffstat (limited to 'src/nix')
-rw-r--r-- | src/nix/path-info.cc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/nix/path-info.cc b/src/nix/path-info.cc index fa4f45fb429d..916ed360e62d 100644 --- a/src/nix/path-info.cc +++ b/src/nix/path-info.cc @@ -5,8 +5,6 @@ #include "common-args.hh" #include <algorithm> -#include <boost/format.hpp> -#include <iomanip> using namespace nix; @@ -21,7 +19,7 @@ struct CmdPathInfo : StorePathsCommand, MixJSON { mkFlag('s', "size", "print size of the NAR dump of each path", &showSize); mkFlag('S', "closure-size", "print sum size of the NAR dumps of the closure of each path", &showClosureSize); - mkFlag('H', "human-readable", "with -s and -S, print sizes like 1K 234M 5.67G etc.", &humanReadable); + mkFlag('h', "human-readable", "with -s and -S, print sizes like 1K 234M 5.67G etc.", &humanReadable); mkFlag(0, "sigs", "show signatures", &showSigs); } @@ -44,7 +42,7 @@ struct CmdPathInfo : StorePathsCommand, MixJSON }, Example{ "To show a package's closure size and all its dependencies with human readable sizes:", - "nix path-info -rsSH nixpkgs.rust" + "nix path-info -rsSh nixpkgs.rust" }, Example{ "To check the existence of a path in a binary cache:", @@ -65,10 +63,10 @@ struct CmdPathInfo : StorePathsCommand, MixJSON }; } - void printSize(int value) + void printSize(unsigned long long value) { if (!humanReadable) { - std::cout << '\t' << boost::format("%11d") % value; + std::cout << fmt("\t%11d", value); return; } @@ -81,7 +79,7 @@ struct CmdPathInfo : StorePathsCommand, MixJSON ++power; res /= 1024; } - std::cout << '\t' << boost::format("%11.1f") % res << idents[power]; + std::cout << fmt("\t%6.1f%c", res, idents.at(power)); } void run(ref<Store> store, Paths storePaths) override |