[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
patch for /bin/ls
From: |
Schirmer |
Subject: |
patch for /bin/ls |
Date: |
Tue, 24 Apr 2001 16:26:58 +0200 |
Hello,
below is a little patch for /usr/src/fileutils-4.0/src/ls.c
which solves the problem that if with "ls -l" the file size
is more than 8 digits, the column alignment is broken.
The patch provides more character positions
for the file size if the group name (often "users" or "root")
is less than 8 chars long, thus instead of:
-rw-r--r-- 1 oskar users 39402356 Apr 20 16:53 from_kfir.PS.iso13818.TS
-rw-r--r-- 1 oskar users 203529648 Apr 20 17:13
from_kfir.PS.iso13818.TS.lis
you get now:
-rw-r--r-- 1 oskar users 39402356 Apr 20 16:53 from_kfir.PS.iso13818.TS
-rw-r--r-- 1 oskar users 203529648 Apr 20 17:13
from_kfir.PS.iso13818.TS.lis
thanks for Your patience, have fun,
Oskar
-------- snipp snapp --------
--- ls.c.old Tue Apr 24 15:52:42 2001
+++ ls.c Tue Apr 24 16:12:24 2001
@@ -2188,6 +2188,7 @@
struct tm *when_local;
const char *fmt;
char *user_name;
+ int mfw;
#if HAVE_ST_DM_MODE
/* Cray DMF: look at the file's migrated, not real, status */
@@ -2260,28 +2261,30 @@
user_name = (numeric_ids ? NULL : getuser (f->stat.st_uid));
if (user_name)
- sprintf (p, "%-8.8s ", user_name);
+ sprintf (p, "%-8.8s", user_name);
else
- sprintf (p, "%-8u ", (unsigned int) f->stat.st_uid);
+ sprintf (p, "%-8u", (unsigned int) f->stat.st_uid);
p += strlen (p);
+ mfw = 0;
if (!inhibit_group)
{
char *group_name = (numeric_ids ? NULL : getgroup (f->stat.st_gid));
if (group_name)
- sprintf (p, "%-8.8s ", group_name);
+ sprintf (p, " %-.8s", group_name);
else
- sprintf (p, "%-8u ", (unsigned int) f->stat.st_gid);
- p += strlen (p);
+ sprintf (p, " %u", (unsigned int) f->stat.st_gid);
+ p += (mfw = strlen (p));
+ mfw = 9 - mfw; /* number of unused blanks at end of group name */
}
if (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode))
- sprintf (p, "%3u, %3u ", (unsigned) major (f->stat.st_rdev),
+ sprintf (p, " %*u, %3u ", mfw+3, (unsigned) major (f->stat.st_rdev),
(unsigned) minor (f->stat.st_rdev));
else
{
char hbuf[LONGEST_HUMAN_READABLE + 1];
- sprintf (p, "%8s ",
+ sprintf (p, " %*s ", mfw+8,
human_readable ((uintmax_t) f->stat.st_size, hbuf, 1,
output_block_size < 0 ? output_block_size : 1));
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- patch for /bin/ls,
Schirmer <=