Re: Size for Size is too small (ls/du)

Matthias Schniedermeyer <[email protected]>
Newsgroups gmane.comp.gnu.fileutils.bugs
Message-ID <[email protected]>
Hi




>    >    File-sizes get bigger. I have regularly files that are >=
>    >    1.000.000.000 bytes. This makes ls output a bit "difficult" to read
>    >    and the format is "jumpy" if they are mixed with files <=
>    >    999.999.999 in size.
>    >
>    > Why not just use --human-readable?  I would have a hard time reading
>    > several lines of files that have such big sizes.
>
>    I sometimes need the exact size.
>
> Then I suggest that you clean up your patch, follow the GNU Coding
> Standard and make a nice ChangeLog entry (you can read about the
> format of those in the GNU Coding Standard) and post the patch here.
> Who knows, maybe it will be included.

OK. Here we go.

ls is changing a 8 into e.g. 11 (I used 11 = 99GB)

Maybe an ever greate size should be used to reduce the liklyhood that
these size has to be increased in some years, again. ;-)

(fileutils-4.1)
- snip -
--- src/ls.c-vanilla    Thu Jan 16 13:33:07 2003
+++ src/ls.c    Wed Jan 15 23:19:11 2003
@@ -2529,7 +2529,7 @@
   else
     {
       char hbuf[LONGEST_HUMAN_READABLE + 1];
-      sprintf (p, "%8s ",
+      sprintf (p, "%11s ",
               human_readable ((uintmax_t) f->stat.st_size, hbuf, 1,
                               output_block_size < 0 ? output_block_size : 1));
     }
- snip -

du is a bit more "complicated". I stripped the Tab-char and made the left
column 11 chars wide(left aligned)

This may be a problem for programs parsing the du output.!

- snip -
--- src/du.c-vanilla    Thu Jan 16 13:33:12 2003
+++ src/du.c    Wed Jan 15 23:22:55 2003
@@ -300,7 +300,7 @@
 print_size (uintmax_t n_blocks, const char *string)
 {
   char buf[LONGEST_HUMAN_READABLE + 1];
-  printf ("%s\t%s\n",
+  printf ("%-11s %s\n",
          human_readable_inexact (n_blocks, buf, ST_NBLOCKSIZE,
                                  output_block_size, human_ceiling),
          string);
- snip -


Changelog-Entry:
- snip -
--- ChangeLog-vanilla   Thu Jan 16 13:39:36 2003
+++ ChangeLog   Thu Jan 16 13:38:42 2003
@@ -1,3 +1,10 @@
+2002-01-16  Matthias Schniedermeyer <[email protected]>
+
+       * src/ls.c: Increased size of size-column from 8 to 11 chars
+
+       * src/du.c: Removed Tab-charactar from output
+       Made left column 11 chars wide
+
 2001-04-29  Jim Meyering  <[email protected]>

        * Version 4.1.
- snip -





Bis denn

-- 
Real Programmers consider "what you see is what you get" to be just as
bad a concept in Text Editors as it is in women. No, the Real Programmer
wants a "you asked for it, you got it" text editor -- complicated,
cryptic, powerful, unforgiving, dangerous.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.