]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(print_header, show_dev): Use a column width that
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Aug 2006 03:59:14 +0000 (03:59 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Aug 2006 03:59:14 +0000 (03:59 +0000)
depends on the block size of -P is specified and not autoscaling.

ChangeLog
src/df.c

index 2123879de664c2273caae9542dc6dd0dd5248f7d..e35cb3339d12f07fa86f3620e9ed0d71a87ed372 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-08-21  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * src/df.c (print_header, show_dev): Use a column width that
+       depends on the block size of -P is specified and not autoscaling.
+       Problem reported by Gustavo G. Rondina in:
+       http://lists.gnu.org/archive/html/bug-coreutils/2006-08/msg00164.html
+
 2006-08-21  Jim Meyering  <jim@meyering.net>
 
        * tests/dircolors/simple (a): Don't fail with an unexpected diagnostic
index 7cbc5229a1e8f7d91cb703bc55c21267b6c6e369..7d7bf1b187ab3e827ed060817595b4d0e1139849 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -163,7 +163,7 @@ print_header (void)
        printf (_("     Size   Used  Avail Use%%"));
     }
   else if (posix_format)
-    printf (_(" %4s-blocks      Used Available Capacity"),
+    printf (_(" %s-blocks      Used Available Capacity"),
            umaxtostr (output_block_size, buf));
   else
     {
@@ -275,6 +275,7 @@ show_dev (char const *disk, char const *mount_point,
   struct fs_usage fsu;
   char buf[3][LONGEST_HUMAN_READABLE + 2];
   int width;
+  int col1_adjustment = 0;
   int use_width;
   uintmax_t input_units;
   uintmax_t output_units;
@@ -356,9 +357,19 @@ show_dev (char const *disk, char const *mount_point,
     }
   else
     {
-      width = (human_output_opts & human_autoscale
-              ? 5 + ! (human_output_opts & human_base_1024)
-              : 9);
+      if (human_output_opts & human_autoscale)
+       width = 5 + ! (human_output_opts & human_base_1024);
+      else
+       {
+         width = 9;
+         if (posix_format)
+           {
+             uintmax_t b;
+             col1_adjustment = -3;
+             for (b = output_block_size; 9 < b; b /= 10)
+               col1_adjustment++;
+           }
+       }
       use_width = ((posix_format
                    && ! (human_output_opts & human_autoscale))
                   ? 8 : 4);
@@ -380,8 +391,9 @@ show_dev (char const *disk, char const *mount_point,
     }
 
   printf (" %*s %*s %*s ",
-         width, df_readable (false, total,
-                             buf[0], input_units, output_units),
+         width + col1_adjustment,
+         df_readable (false, total,
+                      buf[0], input_units, output_units),
          width, df_readable (negate_used, used,
                              buf[1], input_units, output_units),
          width, df_readable (negate_available, available,