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

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


>    OK. Here we go.
>
> Make it an option, and it might just be usefull.  Changing the default
> is silly since most files tend to be far smaller than 1GB, and this
> just wastes precious space on the screen.  Would you like to do this?
>
> You could look at the some of the output formating switches to see how
> it is done for similar things.

Here we go. again.




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.

_______________________________________________
Bug-fileutils mailing list
[email protected]
http://mail.gnu.org/mailman/listinfo/bug-fileutils
broader_sizes.diff (text/plain, 5.7 KB)
--- src/ls.c-vanilla	Thu Jan 16 15:44:34 2003
+++ src/ls.c	Thu Jan 16 16:15:01 2003
@@ -483,6 +483,10 @@
 
 static enum indicator_style indicator_style;
 
+/* Nonzero means use a bigger column for filesize -e */
+
+static int broader_sizes = 0;
+
 /* Names of indicator styles.  */
 static char const *const indicator_style_args[] =
 {
@@ -672,6 +676,7 @@
   {"escape", no_argument, 0, 'b'},
   {"directory", no_argument, 0, 'd'},
   {"dired", no_argument, 0, 'D'},
+  {"broader-sizes", no_argument, 0, 'e'},
   {"full-time", no_argument, 0, FULL_TIME_OPTION},
   {"human-readable", no_argument, 0, 'h'},
   {"inode", no_argument, 0, 'i'},
@@ -1076,7 +1081,7 @@
     }
 
   while ((c = getopt_long (argc, argv,
-			   "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UX1",
+			   "abcdefghiklmnopqrstuvw:xABCDFGHI:LNQRST:UX1",
 			   long_options, NULL)) != -1)
     {
       switch (c)
@@ -1101,6 +1106,10 @@
 	  immediate_dirs = 1;
 	  break;
 
+	case 'e':
+	  broader_sizes = 1;
+	  break;
+
 	case 'f':
 	  /* Same as enabling -a -U and disabling -l -s.  */
 	  all_files = 1;
@@ -2529,9 +2538,18 @@
   else
     {
       char hbuf[LONGEST_HUMAN_READABLE + 1];
-      sprintf (p, "%8s ",
-	       human_readable ((uintmax_t) f->stat.st_size, hbuf, 1,
-			       output_block_size < 0 ? output_block_size : 1));
+      if (!broader_sizes)
+	{
+	  sprintf (p, "%8s ",
+		   human_readable ((uintmax_t) f->stat.st_size, hbuf, 1,
+				   output_block_size < 0 ? output_block_size : 1));
+	}
+      else
+	{
+	  sprintf (p, "%12s ",
+		   human_readable ((uintmax_t) f->stat.st_size, hbuf, 1,
+				   output_block_size < 0 ? output_block_size : 1));
+	}
     }
 
   p += strlen (p);
@@ -3268,6 +3286,7 @@
                                types.  WHEN may be `never', `always', or `auto'\n\
   -d, --directory            list directory entries instead of contents\n\
   -D, --dired                generate output designed for Emacs' dired mode\n\
+  -e, --broader-sizes        print sizes in a broader column\n\
   -f                         do not sort, enable -aU, disable -lst\n\
   -F, --classify             append indicator (one of */=@|) to entries\n\
       --format=WORD          across -x, commas -m, horizontal -x, long -l,\n\
--- man/ls.1-vanilla	Thu Jan 16 16:06:03 2003
+++ man/ls.1	Thu Jan 16 16:15:29 2003
@@ -45,6 +45,9 @@
 \fB\-D\fR, \fB\-\-dired\fR
 generate output designed for Emacs' dired mode
 .TP
+\fB\-e\fR, \fB\-\-broader\-sizes\fR
+print sizes in a broader column
+.TP
 \fB\-f\fR
 do not sort, enable \fB\-aU\fR, disable \fB\-lst\fR
 .TP
--- src/du.c-vanilla	Thu Jan 16 15:44:38 2003
+++ src/du.c	Thu Jan 16 16:14:35 2003
@@ -140,6 +140,9 @@
    if negative, the human-readable base.  */
 static int output_block_size;
 
+/* Nonzero means use a broader column for sizes -e */
+static int broader_sizes = 0;
+
 /* Accumulated path for file or directory being processed.  */
 static String *path;
 
@@ -173,6 +176,7 @@
   {"all", no_argument, NULL, 'a'},
   {"block-size", required_argument, 0, BLOCK_SIZE_OPTION},
   {"bytes", no_argument, NULL, 'b'},
+  {"broader-sizes", no_argument, NULL, 'e'},
   {"count-links", no_argument, NULL, 'l'},
   {"dereference", no_argument, NULL, 'L'},
   {"dereference-args", no_argument, NULL, 'D'},
@@ -209,6 +213,7 @@
   -b, --bytes           print size in bytes\n\
   -c, --total           produce a grand total\n\
   -D, --dereference-args  dereference PATHs when symbolic link\n\
+  -e, --broader-sizes   print sizes in a broader column\n\
   -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)\n\
   -H, --si              likewise, but use powers of 1000 not 1024\n\
   -k, --kilobytes       like --block-size=1024\n\
@@ -300,11 +305,21 @@
 print_size (uintmax_t n_blocks, const char *string)
 {
   char buf[LONGEST_HUMAN_READABLE + 1];
-  printf ("%s\t%s\n",
-	  human_readable_inexact (n_blocks, buf, ST_NBLOCKSIZE,
-				  output_block_size, human_ceiling),
-	  string);
-  fflush (stdout);
+  if (broader_sizes)
+    {
+      printf ("%-12s%s\n",
+	      human_readable_inexact (n_blocks, buf, ST_NBLOCKSIZE,
+				      output_block_size, human_ceiling),
+	      string);
+    }
+  else
+    {
+      printf ("%s\t%s\n",
+	      human_readable_inexact (n_blocks, buf, ST_NBLOCKSIZE,
+				      output_block_size, human_ceiling),
+	      string);
+      fflush (stdout);
+    }
 }
 
 /* Reset the hash structure in the global variable `htab' to
@@ -668,7 +683,7 @@
 
   human_block_size (getenv ("DU_BLOCK_SIZE"), 0, &output_block_size);
 
-  while ((c = getopt_long (argc, argv, "abchHklmsxDLSX:", long_options, NULL))
+  while ((c = getopt_long (argc, argv, "abcehHklmsxDLSX:", long_options, NULL))
 	 != -1)
     {
       long int tmp_long;
@@ -689,6 +704,10 @@
 	  print_totals = 1;
 	  break;
 
+	case 'e':
+	  broader_sizes = 1;
+	  break;
+
 	case 'h':
 	  output_block_size = -1024;
 	  break;
--- man/du.1-vanilla	Thu Jan 16 16:05:58 2003
+++ man/du.1	Thu Jan 16 16:15:25 2003
@@ -24,6 +24,9 @@
 \fB\-D\fR, \fB\-\-dereference\-args\fR
 dereference PATHs when symbolic link
 .TP
+\fB\-e\fR, \fB\-\-border\-sizes\fR
+print sizes in a broader column
+.TP
 \fB\-h\fR, \fB\-\-human\-readable\fR
 print sizes in human readable format (e.g., 1K 234M 2G)
 .TP
--- ChangeLog-vanilla	Sun Apr 29 13:33:43 2001
+++ ChangeLog	Thu Jan 16 16:19:35 2003
@@ -1,3 +1,13 @@
+2003-01-19  Matthias Schniedermeyer  <[email protected]>
+
+	* src/ls.c: Added option for broader sizes
+
+	* man/ls.1: Added option for broader sizes
+
+	* src/du.c: Added option for broader sizes
+
+	* man/du.1: Added option for broader sizes
+
 2001-04-29  Jim Meyering  <[email protected]>
 
 	* Version 4.1.
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.