[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#7176: [PATCH] human: add unambiguous block_size_args
From: |
Pádraig Brady |
Subject: |
bug#7176: [PATCH] human: add unambiguous block_size_args |
Date: |
Sun, 14 Apr 2013 00:52:03 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
forcemerge 14113 7176
stop
On 04/01/2013 01:38 PM, Mihai Capotă wrote:
> The units used in the outputs of "human-readable" and "si" look
> identical when "K/k" is not present. Add two block_size_args, "binary"
> and "decimal", that disambiguate between the outputs of "human-readable"
> and "si" by adding human_B to the list of options.
>
> See bug 7176 in GNU coreutils,
> <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7176>.
> ---
> lib/human.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/lib/human.c b/lib/human.c
> index 613dc65..66a1835 100644
> --- a/lib/human.c
> +++ b/lib/human.c
> @@ -394,11 +394,21 @@ human_readable (uintmax_t n, char *buf, int opts,
> # define DEFAULT_BLOCK_SIZE 1024
> #endif
>
> -static char const *const block_size_args[] = { "human-readable", "si", 0 };
> +static char const *const block_size_args[] =
> + {
> + "human-readable",
> + "si",
> + "binary",
> + "decimal",
> + 0
> + };
> +
> static int const block_size_opts[] =
> {
> human_autoscale + human_SI + human_base_1024,
> - human_autoscale + human_SI
> + human_autoscale + human_SI,
> + human_autoscale + human_SI + human_base_1024 + human_B,
> + human_autoscale + human_SI + human_B
> };
So I was 50:50 on making this change, and in the meantime numfmt(1) was
released,
which gives full control over number formatting, albeit in a more
verbose/explicit form.
thanks,
Pádraig