about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/nix/path-info.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/nix/path-info.cc b/src/nix/path-info.cc
index ee48d483c7ef..fa4f45fb429d 100644
--- a/src/nix/path-info.cc
+++ b/src/nix/path-info.cc
@@ -4,8 +4,9 @@
 #include "json.hh"
 #include "common-args.hh"
 
-#include <iomanip>
 #include <algorithm>
+#include <boost/format.hpp>
+#include <iomanip>
 
 using namespace nix;
 
@@ -67,20 +68,20 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
     void printSize(int value)
     {
         if (!humanReadable) {
-            std::cout << '\t' << std::setw(11) << value;
+            std::cout << '\t' << boost::format("%11d") % value;
             return;
         }
 
-        static constexpr std::array<char, 6> idents = {
-            ' ', 'K', 'M', 'G', 'T', 'P'
+        static constexpr std::array<char, 9> idents = {
+            ' ', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'
         };
         size_t power = 0;
         double res = value;
-        while (res > 1024) {
+        while (res > 1024 && power < idents.size()) {
             ++power;
             res /= 1024;
         }
-        std::cout << '\t' << std::setw(11) << std::setprecision(3) << res << idents[power];
+        std::cout << '\t' << boost::format("%11.1f") % res << idents[power];
     }
 
     void run(ref<Store> store, Paths storePaths) override