diff options
Diffstat (limited to 'src/output.c')
| -rw-r--r-- | src/output.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/output.c b/src/output.c index 644a6a6..8e57bcd 100644 --- a/src/output.c +++ b/src/output.c @@ -194,8 +194,20 @@ inline void out_print_user_name(struct list_node *ptr) { } inline void out_print_size(struct list_node *ptr) { - printf(" %8ld %2s ", ((ptr->ln_stat.st_size>=1024) ? (ptr->ln_stat.st_size/1024) : ptr->ln_stat.st_size), - ((ptr->ln_stat.st_size >= 1024) ? "kB" : "")); + char unit[4] = ""; + off_t tmp = ptr->ln_stat.st_size; + if (tmp >= 1024) { + tmp /= 1024; + unit[0] = 'K'; + unit[1] = 'i'; + unit[2] = 'B'; + /* > 10 GiB as MiB */ + if (tmp > (10*1024*1024)) { + tmp /= 1024; + unit[0] = 'M'; + } + } + printf(" %8ld %3s ", tmp, unit); } inline void out_print_time(time_t tv) { @@ -399,7 +411,7 @@ inline void out_print_format_string_header(const char *format, size_t longest_fn LOCAL_EXTEND_SEP_LINE(); break; case 's': - sprintf(pos, " %11s ", "SIZE "); + sprintf(pos, " %12s ", "SIZE "); LOCAL_EXTEND_SEP_LINE(); break; case 't': |
