summaryrefslogtreecommitdiff
path: root/src/ls.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-08-10 07:51:52 +0000
committerJim Meyering <jim@meyering.net>2001-08-10 07:51:52 +0000
commit67ba4ac017674c8800f26aa51f87bf70cd222e97 (patch)
tree75f1cbca716ab9e1a367d80d7f289e9d7478e8ff /src/ls.c
parentb84a28d9dd72ba2fde20921f600a400eea74c922 (diff)
downloadcoreutils-67ba4ac017674c8800f26aa51f87bf70cd222e97.tar.xz
(print_long_format): If a file size is negative, assume
the typical case where it has wrapped around from a positive value.
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ls.c b/src/ls.c
index 6c2cefabc..dbbac57b2 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -2637,8 +2637,17 @@ print_long_format (const struct fileinfo *f)
else
{
char hbuf[LONGEST_HUMAN_READABLE + 1];
+ uintmax_t size = f->stat.st_size;
+
+ /* POSIX requires that the size be printed without a sign, even
+ when negative. Assume the typical case where negative sizes
+ are actually positive values that have wrapped around. */
+ if (sizeof f->stat.st_size < sizeof size)
+ size += ((uintmax_t) (f->stat.st_size < 0)
+ << (sizeof f->stat.st_size * CHAR_BIT));
+
sprintf (p, "%8s ",
- human_readable ((uintmax_t) f->stat.st_size, hbuf, 1,
+ human_readable (size, hbuf, 1,
output_block_size < 0 ? output_block_size : 1));
}