On Tue, Mar 03, 2015 at 06:11:55PM +0200, Ari Sundholm wrote:
> I wrote this for my own purposes and cleaned it up in hopes it is useful.
> 
> Signed-off-by: Ari Sundholm <[email protected]>
> ---
>  coreutils/truncate.c | 92 
> ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 92 insertions(+)
>  create mode 100644 coreutils/truncate.c
> 
> diff --git a/coreutils/truncate.c b/coreutils/truncate.c
> new file mode 100644
> index 0000000..f997cd2
> --- /dev/null
> +++ b/coreutils/truncate.c

> +static const struct suffix_mult truncate_suffixes[] = {
> +     { "c", 1 },
> +     { "w", 2 },
> +     { "b", 512 },
> +     { "kB", 1000 },
> +     { "kD", 1000 },
> +     { "k", 1024 },
> +     { "K", 1024 },  /* compat with coreutils dd (it also accepts KB and KD, 
> TODO?) */
> +     { "MB", 1000000 },
> +     { "MD", 1000000 },
> +     { "M", 1024*1024 },
> +     { "GB", 1000000000 },
> +     { "GD", 1000000000 },
> +     { "G", 1024*1024*1024 },
> +     /* "D" suffix for decimal is not in coreutils manpage, looks like it's 
> deprecated */
> +     /* coreutils also understands TPEZY suffixes for tera- and so on, with 
> B suffix for decimal */
> +     { "", 0 }
> +};

Was this copy-pasted from coreutils/dd.c?
The bloat could be reduced by making it shared between dd and truncate;
if my math is right, this table is at least 87 bytes.

Thanks,
Isaac Dunham
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to