summaryrefslogtreecommitdiff
path: root/src/df.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1998-09-07 18:08:09 +0000
committerJim Meyering <jim@meyering.net>1998-09-07 18:08:09 +0000
commit584f4d85cf01a5ce84b4682228d879584bb479b8 (patch)
tree1b762791de03e5e4d90e862c6a0ff5f8e4f18199 /src/df.c
parent9096ee8e42dcb3a323a08a24a68eaa1d77d30209 (diff)
downloadcoreutils-584f4d85cf01a5ce84b4682228d879584bb479b8.tar.xz
(show_dev) [!posix_format]: When using --print-type,
let the device path and the file system type share a single (wider) field if their combined lengths allow it. From Andries Brouwer.
Diffstat (limited to 'src/df.c')
-rw-r--r--src/df.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/df.c b/src/df.c
index a51915a2b..415d4fec7 100644
--- a/src/df.c
+++ b/src/df.c
@@ -246,15 +246,29 @@ show_dev (const char *disk, const char *mount_point, const char *fstype,
if (! disk)
disk = "-"; /* unknown */
-
- printf ((print_type ? "%-13s" : "%-20s"), disk);
- if ((int) strlen (disk) > (print_type ? 13 : 20) && !posix_format)
- printf ((print_type ? "\n%13s" : "\n%20s"), "");
-
if (! fstype)
fstype = "-"; /* unknown */
+
+ /* df.c reserved 5 positions for fstype,
+ but that does not suffice for type iso9660 */
if (print_type)
- printf (" %-5s ", fstype);
+ {
+ int disk_name_len = (int) strlen (disk);
+ int fstype_len = (int) strlen (fstype);
+ if (disk_name_len + fstype_len + 2 < 20)
+ printf ("%s%*s ", disk, 18 - disk_name_len, fstype);
+ else if (!posix_format)
+ printf ("%s\n%18s ", disk, fstype);
+ else
+ printf ("%s %s", disk, fstype);
+ }
+ else
+ {
+ if ((int) strlen (disk) > 20 && !posix_format)
+ printf ("%s\n%20s", disk, "");
+ else
+ printf ("%-20s", disk);
+ }
if (inode_format)
{