summaryrefslogtreecommitdiff
path: root/src/ls.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-12-31 21:33:51 +0000
committerJim Meyering <jim@meyering.net>1997-12-31 21:33:51 +0000
commitb76a4533046163978f7517f9ea6d3307bfa0a98a (patch)
tree2cc92de99380aaaaab7fddb38b1f781a83906bb5 /src/ls.c
parent069e564d89f706f2d4cd29162fff73fc2b115067 (diff)
downloadcoreutils-b76a4533046163978f7517f9ea6d3307bfa0a98a.tar.xz
(decode_switches): -h and -H override output units.
(print_dir, gobble_file, print_long_format, print_file_name_and_frills): Print disk allocations human readably.
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/ls.c b/src/ls.c
index 5d0550ce6..4f28157a9 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1179,6 +1179,9 @@ decode_switches (int argc, char **argv)
}
}
+ if (human_readable_base)
+ output_units = 1;
+
return optind;
}
@@ -1594,7 +1597,8 @@ print_dir (const char *name, const char *realname)
p = _("total");
FPUTS (p, stdout, strlen (p));
PUTCHAR (' ');
- p = human_readable (total_blocks, buf, ST_NBLOCKSIZE, output_units, 0);
+ p = human_readable (total_blocks, buf, ST_NBLOCKSIZE, output_units,
+ human_readable_base);
FPUTS (p, stdout, strlen (p));
PUTCHAR ('\n');
}
@@ -1782,7 +1786,7 @@ gobble_file (const char *name, int explicit_arg, const char *dirname)
{
char buf[LONGEST_HUMAN_READABLE + 1];
int len = strlen (human_readable (blocks, buf, ST_NBLOCKSIZE,
- output_units, 0));
+ output_units, human_readable_base));
if (block_size_size < len)
block_size_size = len < 7 ? len : 7;
}
@@ -2205,7 +2209,8 @@ print_long_format (const struct fileinfo *f)
char hbuf[LONGEST_HUMAN_READABLE + 1];
sprintf (p, "%*s ", block_size_size,
human_readable ((uintmax_t) ST_NBLOCKS (f->stat), hbuf,
- ST_NBLOCKSIZE, output_units, 0));
+ ST_NBLOCKSIZE, output_units,
+ human_readable_base));
p += strlen (p);
}
@@ -2482,7 +2487,7 @@ print_file_name_and_frills (const struct fileinfo *f)
if (print_block_size)
printf ("%*s ", block_size_size,
human_readable ((uintmax_t) ST_NBLOCKS (f->stat), buf,
- ST_NBLOCKSIZE, output_units, 0));
+ ST_NBLOCKSIZE, output_units, human_readable_base));
print_name_with_quoting (f->name, f->stat.st_mode, f->linkok, NULL);