* A wrapper for humanize_number that autoscales, since the * HN_AUTOSCALE flag scales as needed based on the size of * the output buffer, not the size of the value. I also * wish HN_DECIMAL was more imperative, without the <10 * test. But the boat only goes where we want when we hold * the rudder, so xo_humanize fixes part of the problem. */
| 3708 | * the rudder, so xo_humanize fixes part of the problem. |
| 3709 | */ |
| 3710 | static ssize_t |
| 3711 | xo_humanize (char *buf, ssize_t len, uint64_t value, int flags) |
| 3712 | { |
| 3713 | int scale = 0; |
| 3714 | |
| 3715 | if (value) { |
| 3716 | uint64_t left = value; |
| 3717 | |
| 3718 | if (flags & HN_DIVISOR_1000) { |
| 3719 | for ( ; left; scale++) |
| 3720 | left /= 1000; |
| 3721 | } else { |
| 3722 | for ( ; left; scale++) |
| 3723 | left /= 1024; |
| 3724 | } |
| 3725 | scale -= 1; |
| 3726 | } |
| 3727 | |
| 3728 | return xo_humanize_number(buf, len, value, "", scale, flags); |
| 3729 | } |
| 3730 | |
| 3731 | /* |
| 3732 | * This is an area where we can save information from the handle for |
no test coverage detected