]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(df_readable): New arg for rounding style.
authorJim Meyering <jim@meyering.net>
Fri, 16 Jun 2000 12:49:20 +0000 (12:49 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 16 Jun 2000 12:49:20 +0000 (12:49 +0000)
Round negative numbers correctly.
(show_dev): Round disk usage up and disk free space down.

src/df.c

index f5ca9016e254d76e7f0b3a66e781634f8f29f850..a6bc20c056a395dc19e7e6e3e521cef391bd9621 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -209,12 +209,12 @@ excluded_fstype (const char *fstype)
   return 0;
 }
 
-/* Like human_readable, except return "-" if the argument is -1,
-   return the negative of N if NEGATIVE is 1,
-   and take ceiling of fractions if posix_format.  */
+/* Like human_readable_inexact, except return "-" if the argument is -1,
+   and return the negative of N if NEGATIVE is 1.  */
 static char const *
 df_readable (int negative, uintmax_t n, char *buf,
-            int from_block_size, int t_output_block_size)
+            int from_block_size, int t_output_block_size,
+            enum human_inexact_style s)
 {
   if (n == -1)
     return "-";
@@ -223,9 +223,7 @@ df_readable (int negative, uintmax_t n, char *buf,
       char *p = human_readable_inexact (negative ? - n : n,
                                        buf + negative, from_block_size,
                                        t_output_block_size,
-                                       (posix_format
-                                        ? human_ceiling
-                                        : human_round_to_even));
+                                       negative ? - s : s);
       if (negative)
        *--p = '-';
       return p;
@@ -347,11 +345,16 @@ show_dev (const char *disk, const char *mount_point, const char *fstype,
 
   printf (" %*s %*s %*s ",
          width, df_readable (0, total,
-                             buf[0], input_units, output_units),
+                             buf[0], input_units, output_units,
+                             (posix_format
+                              ? human_ceiling
+                              : human_round_to_even)),
          width, df_readable (negate_used, used,
-                             buf[1], input_units, output_units),
+                             buf[1], input_units, output_units,
+                             human_ceiling),
          width, df_readable (negate_available, available,
-                             buf[2], input_units, output_units));
+                             buf[2], input_units, output_units,
+                             posix_format ? human_ceiling : human_floor));
 
   if (used != -1 && available != -1)
     {