Your message dated Sun, 13 Nov 2005 13:08:03 -0500
with message-id <[EMAIL PROTECTED]>
and subject line prettyprint ls -l with long usernames
has caused the attached Bug report to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere. Please contact me immediately.)
Debian bug tracking system administrator
(administrator, Debian Bugs database)
--------------------------------------
Received: (at submit) by bugs.debian.org; 18 Aug 2003 08:55:06 +0000
>From [EMAIL PROTECTED] Mon Aug 18 03:55:04 2003
Return-path: <[EMAIL PROTECTED]>
Received: from pd9518e8f.dip.t-dialin.net (extern.mail.waldi.eu.org)
[217.81.142.143]
by master.debian.org with esmtp (Exim 3.35 1 (Debian))
id 19ofn5-0001T0-00; Mon, 18 Aug 2003 03:55:03 -0500
Received: by wavehammer.waldi.eu.org (Postfix, from userid 1000)
id 3A6A274894; Mon, 18 Aug 2003 10:55:01 +0200 (CEST)
Date: Mon, 18 Aug 2003 10:55:01 +0200
From: Bastian Blank <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: coreutils - modify output of ls -l
Message-ID: <[EMAIL PROTECTED]>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
protocol="application/pgp-signature"; boundary="DBIVS5p969aUjpLe"
Content-Disposition: inline
User-Agent: Mutt/1.5.4i
Delivered-To: [EMAIL PROTECTED]
X-Spam-Status: No, hits=-7.6 required=4.0
tests=BAYES_01,PGP_SIGNATURE_2,RCVD_IN_NJABL,
RCVD_IN_OSIRUSOFT_COM,USER_AGENT_MUTT
version=2.53-bugs.debian.org_2003_8_17
X-Spam-Level:
X-Spam-Checker-Version: SpamAssassin 2.53-bugs.debian.org_2003_8_17
(1.174.2.15-2003-03-30-exp)
--DBIVS5p969aUjpLe
Content-Type: multipart/mixed; boundary="uAKRQypu60I7Lcqm"
Content-Disposition: inline
--uAKRQypu60I7Lcqm
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Package: coreutils
Version: 5.0.90-1
Severity: wishlist
Tags: patch
this patch modifies the output of ls -l to be better readable for users
which love user-/group-names with length > 8 and large files. it first
calculates the lenght of any of that items and use that value while
printing the output.
bastian
--=20
It would seem that evil retreats when forcibly confronted.
-- Yarnek of Excalbia, "The Savage Curtain", stardate 5906.5
--uAKRQypu60I7Lcqm
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff
Content-Transfer-Encoding: quoted-printable
--- coreutils-5.0.90.orig/src/ls.c 2003-07-27 08:33:36.000000000 +0200
+++ coreutils-5.0.90/src/ls.c 2003-08-18 10:44:50.000000000 +0200
@@ -269,7 +269,7 @@
static void print_dir (const char *name, const char *realname);
static void print_file_name_and_frills (const struct fileinfo *f);
static void print_horizontal (void);
-static void print_long_format (const struct fileinfo *f);
+static void print_long_format (void);
static void print_many_per_line (void);
static void print_name_with_quoting (const char *p, mode_t mode,
int linkok,
@@ -2807,11 +2807,7 @@
break;
=20
case long_format:
- for (i =3D 0; i < files_index; i++)
- {
- print_long_format (files + i);
- DIRED_PUTCHAR ('\n');
- }
+ print_long_format ();
break;
}
}
@@ -2895,20 +2891,65 @@
null. */
=20
static size_t
-format_user (char *buffer, uid_t u)
+format_user (char *buffer, uid_t u, int len)
+{
+ char format[16];
+ const char *name =3D (numeric_ids ? NULL : getuser (u));
+ if (name)
+ sprintf (buffer, "%-*s ", len, name);
+ else
+ sprintf (buffer, "%-*lu ", len, (unsigned long) u);
+ return strlen (buffer);
+}
+
+static size_t
+format_group (char *buffer, gid_t g, int len)
{
- char const *name =3D (numeric_ids ? NULL : getuser (u));
+ char const *name =3D (numeric_ids ? NULL : getgroup (g));
if (name)
- sprintf (buffer, "%-8s ", name);
+ sprintf (buffer, "%-*s ", len, name);
else
- sprintf (buffer, "%-8lu ", (unsigned long) u);
+ sprintf (buffer, "%-*lu ", len, (unsigned long) g);
return strlen (buffer);
}
=20
+static int
+print_long_format_calc_id_len (const struct fileinfo *f)
+{
+ char *user, *group;
+ int len_user =3D 8, len_group =3D 8, len;
+ user =3D getuser (f->stat.st_uid);
+ group =3D getgroup (f->stat.st_uid);
+ if (user)
+ len_user =3D strlen (user);
+ if (group)
+ len_group =3D strlen (group);
+ len =3D MAX (len_user, len_group);
+ if (len > 8)
+ return len;
+ return 8;
+}
+
+static int
+print_long_format_calc_size_len (const struct fileinfo *f)
+{
+ int len;
+ char hbuf[LONGEST_HUMAN_READABLE + 1];
+ uintmax_t size =3D f->stat.st_size;
+
+ size +=3D (f->stat.st_size < 0) * ((uintmax_t) OFF_T_MAX - OFF_T_MIN + 1=
);
+
+ len =3D strlen (human_readable (size, hbuf, human_output_opts, 1, file_o=
utput_block_size));
+
+ if (len > 8)
+ return len;
+ return 8;
+}
+
/* Print information about F in long format. */
=20
static void
-print_long_format (const struct fileinfo *f)
+print_long_format_one (const struct fileinfo *f, int id_len, int size_len)
{
char modebuf[12];
char init_bigbuf
@@ -2979,20 +3020,13 @@
p +=3D strlen (p);
=20
if (print_owner)
- p +=3D format_user (p, f->stat.st_uid);
+ p +=3D format_user (p, f->stat.st_uid, id_len);
=20
if (print_group)
- {
- char const *group_name =3D (numeric_ids ? NULL : getgroup (f->stat.s=
t_gid));
- if (group_name)
- sprintf (p, "%-8s ", group_name);
- else
- sprintf (p, "%-8lu ", (unsigned long) f->stat.st_gid);
- p +=3D strlen (p);
- }
+ p +=3D format_group (p, f->stat.st_gid, id_len);
=20
if (print_author)
- p +=3D format_user (p, f->stat.st_author);
+ p +=3D format_user (p, f->stat.st_author, id_len);
=20
if (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode))
sprintf (p, "%3lu, %3lu ",
@@ -3008,7 +3042,7 @@
are actually positive values that have wrapped around. */
size +=3D (f->stat.st_size < 0) * ((uintmax_t) OFF_T_MAX - OFF_T_MIN=
+ 1);
=20
- sprintf (p, "%8s ",
+ sprintf (p, "%*s ", size_len,
human_readable (size, hbuf, human_output_opts,
1, file_output_block_size));
}
@@ -3096,6 +3130,29 @@
print_type_indicator (f->stat.st_mode);
}
=20
+static void
+print_long_format (void)
+{
+ int id_len =3D 0, size_len =3D 0, len_temp, i;
+
+ for (i =3D 0; i < files_index; i++)
+ {
+ len_temp =3D print_long_format_calc_id_len (files + i);
+ if (len_temp > id_len)
+ id_len =3D len_temp;
+ len_temp =3D print_long_format_calc_size_len (files + i);
+ if (len_temp > size_len)
+ size_len =3D len_temp;
+ }
+
+ for (i =3D 0; i < files_index; i++)
+ {
+ print_long_format_one (files + i, id_len, size_len);
+ DIRED_PUTCHAR ('\n');
+ }
+}
+
+
/* Output to OUT a quoted representation of the file name NAME,
using OPTIONS to control quoting. Produce no output if OUT is NULL.
Store the number of screen columns occupied by NAME's quoted
--uAKRQypu60I7Lcqm--
--DBIVS5p969aUjpLe
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iEYEARECAAYFAj9AlGUACgkQLkAIIn9ODhFBpwCgo6Ux7xIl3uL74SXfQ2zvP3GW
ODMAniK2dOfwNad3i0j7KspRcl2wc09F
=mg1H
-----END PGP SIGNATURE-----
--DBIVS5p969aUjpLe--
---------------------------------------
Received: (at 206012-done) by bugs.debian.org; 13 Nov 2005 18:08:04 +0000
>From [EMAIL PROTECTED] Sun Nov 13 10:08:04 2005
Return-path: <[EMAIL PROTECTED]>
Received: from vms048pub.verizon.net ([206.46.252.48])
by spohr.debian.org with esmtp (Exim 4.50)
id 1EbMGq-00042K-Mk
for [EMAIL PROTECTED]; Sun, 13 Nov 2005 10:08:04 -0800
Received: from osgiliath.mathom.us ([70.108.64.202])
by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep
9 2005)) with ESMTPA id <[EMAIL PROTECTED]> for
[EMAIL PROTECTED]; Sun, 13 Nov 2005 12:08:04 -0600 (CST)
Received: from localhost (localhost [127.0.0.1])
by osgiliath.mathom.us (Postfix) with ESMTP id 6E6246031E0 for
<[EMAIL PROTECTED]>; Sun, 13 Nov 2005 13:08:03 -0500 (EST)
Received: from osgiliath.mathom.us ([127.0.0.1])
by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024)
with LMTP id 19682-03 for <[EMAIL PROTECTED]>; Sun,
13 Nov 2005 13:08:03 -0500 (EST)
Received: by osgiliath.mathom.us (Postfix, from userid 1000)
id 2816260049B; Sun, 13 Nov 2005 13:08:03 -0500 (EST)
Date: Sun, 13 Nov 2005 13:08:03 -0500
From: Michael Stone <[EMAIL PROTECTED]>
Subject: prettyprint ls -l with long usernames
To: [EMAIL PROTECTED]
Message-id: <[EMAIL PROTECTED]>
MIME-version: 1.0
Content-type: text/plain; charset=us-ascii; format=flowed
Content-disposition: inline
X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88
X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us
User-Agent: Mutt/1.5.11
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02
(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level:
X-Spam-Status: No, hits=-2.0 required=4.0 tests=BAYES_01 autolearn=no
version=2.60-bugs.debian.org_2005_01_02
Version: 5.93-1
Latest coreutils prints long items nicely:
-rw-rwxr--+ 1 mstone mstone 0 2005-11-13 11:39 bar*
-rw-rwxr--+ 1 mstone mstone 0 2005-11-13 11:39 foo*
-rw-rw-r-- 1 mstone mstone 1099511627777 2005-11-13 13:05 foolarge
-rw-rw-r-- 1 reallylongname mstone 0 2005-11-13 13:06 testusr
-rw-rw-r-- 1 mstone mstone 0 2005-11-13 13:07 x
Mike Stone
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]