df: "support" -H as an alias of -h

function                                             old     new   delta
df_main                                             1065    1068      +3
.rodata                                           104232  104233      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 4/0)                 Total: 4 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2021-09-11 00:47:03 +02:00
parent 40f2dd7dd2
commit 9346ea9550

View File

@ -107,7 +107,8 @@ int df_main(int argc UNUSED_PARAM, char **argv)
OPT_INODE = (1 << 5) * ENABLE_FEATURE_DF_FANCY, OPT_INODE = (1 << 5) * ENABLE_FEATURE_DF_FANCY,
OPT_BSIZE = (1 << 6) * ENABLE_FEATURE_DF_FANCY, OPT_BSIZE = (1 << 6) * ENABLE_FEATURE_DF_FANCY,
OPT_HUMAN = (1 << (4 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE, OPT_HUMAN = (1 << (4 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
OPT_MEGA = (1 << (5 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE, OPT_HUMANDEC = (1 << (5 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
OPT_MEGA = (1 << (6 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
}; };
const char *disp_units_hdr = NULL; const char *disp_units_hdr = NULL;
char *chp, *opt_t; char *chp, *opt_t;
@ -124,7 +125,7 @@ int df_main(int argc UNUSED_PARAM, char **argv)
opt = getopt32(argv, "^" opt = getopt32(argv, "^"
"kPTt:" "kPTt:"
IF_FEATURE_DF_FANCY("aiB:") IF_FEATURE_DF_FANCY("aiB:")
IF_FEATURE_HUMAN_READABLE("hm") IF_FEATURE_HUMAN_READABLE("hHm")
"\0" "\0"
#if ENABLE_FEATURE_HUMAN_READABLE && ENABLE_FEATURE_DF_FANCY #if ENABLE_FEATURE_HUMAN_READABLE && ENABLE_FEATURE_DF_FANCY
"k-mB:m-Bk:B-km" "k-mB:m-Bk:B-km"
@ -151,8 +152,11 @@ int df_main(int argc UNUSED_PARAM, char **argv)
got_it: ; got_it: ;
} }
if (opt & OPT_HUMAN) { if (opt & (OPT_HUMAN|OPT_HUMANDEC)) {
df_disp_hr = 0; df_disp_hr = 0;
//TODO: need to add support in make_human_readable_str() for "decimal human readable"
//if (opt & OPT_HUMANDEC)
// df_disp_hr--;
disp_units_hdr = " Size"; disp_units_hdr = " Size";
} }
if (opt & OPT_INODE) if (opt & OPT_INODE)