Subject: Re: ls -lsh
To: None <tech-userlevel@netbsd.org>
From: Jan Schaumann <jschauma@netmeister.org>
List: tech-userlevel
Date: 08/06/2004 10:00:04
--EeQfGwPcQSOJBaQU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Jan Schaumann <jschauma@netmeister.org> wrote:

> Index: print.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> RCS file: /cvsroot/src/bin/ls/print.c,v
> retrieving revision 1.38
> diff -b -u -r1.38 print.c
> --- print.c	26 Dec 2003 06:19:19 -0000	1.38
> +++ print.c	6 Aug 2004 03:03:22 -0000
> @@ -96,11 +96,19 @@
> =20
>  	if (dp->list->fts_level !=3D FTS_ROOTLEVEL && (f_longform || f_size)) {
>  		if (f_humanize) {
> -			if ((humanize_number(szbuf, sizeof(szbuf), dp->stotal,
> -			    "", HN_AUTOSCALE,
> +			int64_t total;
> +
> +			if (f_size)=20
> +				total =3D 1024 * howmany(dp->btotal, blocksize);

Actually, I think this should be
	=09
	total =3D 512 * dp->btotal;

> +			else
> +				total =3D dp->stotal;
> +
> +			if ((humanize_number(szbuf, sizeof(szbuf),
> +				total, "", HN_AUTOSCALE,
>  			    (HN_DECIMAL | HN_B | HN_NOSPACE))) =3D=3D -1)
>  				err(1, "humanize_number");
>  			(void)printf("total %s\n", szbuf);
> +
>  		} else {
>  			(void)printf("total %llu\n",
>  			    (long long)(howmany(dp->btotal, blocksize)));
> @@ -114,9 +122,19 @@
>  		if (f_inode)
>  			(void)printf("%*lu ", dp->s_inode,
>  			    (unsigned long)sp->st_ino);
> -		if (f_size && !f_humanize) {
> +		if (f_size) {
> +			if (f_humanize) {
> +				if ((humanize_number(szbuf, sizeof(szbuf),
> +					 1024 * howmany(sp->st_blocks, blocksize),

As should this
		512 * sp->st_blocks;


=2E..since I don't think in this example we want to look at BLOCKSIZE.
When humanizing -s, we want to display the actual amount of space used.

I think.

-Jan

--=20
http://www.netbsd.org -
         Multiarchitecture OS, no hype required.

--EeQfGwPcQSOJBaQU
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFBE47kfFtkr68iakwRAjgLAJ4zn+vfmvHo0lTKzdZmZNorW9DQHQCg8IES
RYdTlC/qwG8y6pmf973scZ8=
=MJR1
-----END PGP SIGNATURE-----

--EeQfGwPcQSOJBaQU--