Bug#562971: [Fwd: Bug#562971: Wrong unit when using -h [patch]]

2009-12-30 Thread Steve Baker
Florian Ernst florian_er...@gmx.net wrote:
 Hello Steve,

 FYI, this just in to the Debian BugTrackingSystem at
 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=492570.

 Cheers,
 Flo
...
 From: Ulrich Eckhardt dooms...@knuut.de
...
 Actually there are several aspects to this bug, which is also related 
 to #556186[1]:

 1. The prefix for thousand is k, not K, all others are correctly 
 capitalized.

  The behavior conforms to the behavior of 'ls'. I am not going to change
this.  A capital K has been standard to denote 1024 bytes for as long as I've
been computing.  If he wishes to be asinine about it, it conforms to the JEDEC
Standard 100B.01 defining the prefix to units of semiconductor storage
capacity.  (http://en.wikipedia.org/wiki/JEDEC_memory_standards).

 2. The prefix k means one thousand. Abusing it for 1024 is just that - 
 abuse[2].

  Again the behavior conforms to 'ls' (and many other Unix utilities.)  If he
wants an --si option (ala ls) then he is welcome to code it.

  Note that the manpage 'documented' this bug using the 
 offensive wording reported in #556186. This IMHO doubly asinine phrase 
 was removed in one of the newer releases, but without replacing it 
 with some honest explanation of the prefix abuse.

  This is why people stop making free software.

- Steve



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#562971: Wrong unit when using -h [patch]

2009-12-29 Thread Ulrich Eckhardt
Package: tree
Version: 1.5.2.2-1

Actually there are several aspects to this bug, which is also related 
to #556186[1]:

1. The prefix for thousand is k, not K, all others are correctly 
capitalized.

2. The prefix k means one thousand. Abusing it for 1024 is just that - 
abuse[2]. Note that the manpage 'documented' this bug using the 
offensive wording reported in #556186. This IMHO doubly asinine phrase 
was removed in one of the newer releases, but without replacing it 
with some honest explanation of the prefix abuse.

The attached patch fixes both issues, the latter by using the correct 
meaning of the SI prefixes and not by documenting the bug in the 
manpage. It was made against the pristine upstream 1.5.3 sources.

Cheers!

Uli

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=556186
[2] I'm aware that some people disagree, this is kind of a religious 
matter.
--- tree.c.orig	2009-12-29 17:13:47.0 +0100
+++ tree.c	2009-12-29 18:09:36.0 +0100
@@ -1292,14 +1292,14 @@ void printit(char *s)
 
 void psize(char *buf, off_t size)
 {
-  char *unit=BKMGTPEZY;
+  char *unit= kMGTPEZY;
   int idx;
 
   if (!hflag) sprintf(buf, sizeof(off_t) == sizeof(long long)?  %11lld :  %9ld, size);
   else {
-for (idx=size1024?0:1; size = (1024*1024); idx++,size=10);
+for (idx=size1000?0:1; size = 100; idx++,size/=1000);
 if (!idx) sprintf(buf,  %4d, (int)size);
-else sprintf(buf, ((size10) = 10)?  %3.0f%c :  %3.1f%c, (float)size/(float)1024,unit[idx]);
+else sprintf(buf, (size=1) ?  %3.0f%c :  %3.1f%c, size/1000.0f,unit[idx]);
   }
 }