summaryrefslogtreecommitdiff
path: root/src/df.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-06-16 12:49:20 +0000
committerJim Meyering <jim@meyering.net>2000-06-16 12:49:20 +0000
commitf570d032b4adc1193c96e093b119ec0129508885 (patch)
treee1d49555cbdacde5ba6ca9725b00375ad2d1c7cc /src/df.c
parent0e2ebc67e23c1eb9b1f7fae630ba5d33dcbae238 (diff)
downloadcoreutils-f570d032b4adc1193c96e093b119ec0129508885.tar.xz
(df_readable): New arg for rounding style.
Round negative numbers correctly. (show_dev): Round disk usage up and disk free space down.
Diffstat (limited to 'src/df.c')
-rw-r--r--src/df.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/df.c b/src/df.c
index f5ca9016e..a6bc20c05 100644
--- 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)
{