From 8893023ba27ea87b12a333960271c9f86cdebf7b Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Wed, 4 Mar 2015 18:46:48 +0200 Subject: dd: move suffix struct to xatonum.c This way it can be used by other applets without duplication. Signed-off-by: Ari Sundholm Signed-off-by: Denys Vlasenko --- libbb/xatonum.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libbb') diff --git a/libbb/xatonum.c b/libbb/xatonum.c index 6f4e023bb..19b54fb0c 100644 --- a/libbb/xatonum.c +++ b/libbb/xatonum.c @@ -75,3 +75,22 @@ const struct suffix_mult bkm_suffixes[] = { { "m", 1024*1024 }, { "", 0 } }; + +const struct suffix_mult cwbkMG_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 } +}; -- cgit v1.2.3-55-g6feb From 911db16229d41f53b9c44272fcccdb3552a5a99e Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Sun, 22 Mar 2015 17:55:38 +0100 Subject: truncate: new applet function old new delta truncate_main - 161 +161 cwbkMG_suffixes - 128 +128 packed_usage 30443 30459 +16 applet_names 2512 2521 +9 applet_main 1456 1460 +4 parse_command 1460 1463 +3 applet_nameofs 728 730 +2 applet_install_loc 182 183 +1 dd_suffixes 112 - -112 ------------------------------------------------------------------------------ (add/remove: 3/1 grow/shrink: 10/3 up/down: 337/-133) Total: 204 bytes Signed-off-by: Ari Sundholm Signed-off-by: Denys Vlasenko --- include/libbb.h | 1 + libbb/xatonum.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'libbb') diff --git a/include/libbb.h b/include/libbb.h index 9550c0589..26b686805 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -863,6 +863,7 @@ struct suffix_mult { extern const struct suffix_mult bkm_suffixes[]; #define km_suffixes (bkm_suffixes + 1) extern const struct suffix_mult cwbkMG_suffixes[]; +#define kMG_suffixes (cwbkMG_suffixes + 3) #include "xatonum.h" /* Specialized: */ diff --git a/libbb/xatonum.c b/libbb/xatonum.c index 19b54fb0c..9dd5c3e7e 100644 --- a/libbb/xatonum.c +++ b/libbb/xatonum.c @@ -83,7 +83,9 @@ const struct suffix_mult cwbkMG_suffixes[] = { { "kB", 1000 }, { "kD", 1000 }, { "k", 1024 }, - { "K", 1024 }, /* compat with coreutils dd (it also accepts KB and KD, TODO?) */ + { "KB", 1000 }, /* compat with coreutils dd */ + { "KD", 1000 }, /* compat with coreutils dd */ + { "K", 1024 }, /* compat with coreutils dd */ { "MB", 1000000 }, { "MD", 1000000 }, { "M", 1024*1024 }, -- cgit v1.2.3-55-g6feb