diff options
author | Rob Landley <rob@landley.net> | 2020-09-04 01:04:43 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-09-04 01:04:43 -0500 |
commit | ec5e6e12ee6d7047ab013f3a2826abdb52666ea0 (patch) | |
tree | 0a14a66b2dab3daa67da89d8bf6ce8032ccb5527 /toys/example | |
parent | cb064374c86259f74899162b28c4896e898401e3 (diff) | |
download | toybox-ec5e6e12ee6d7047ab013f3a2826abdb52666ea0.tar.gz |
Add commas to top display, and adjust memory units to megabytes if >10G RAM.
Diffstat (limited to 'toys/example')
-rw-r--r-- | toys/example/demo_number.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/toys/example/demo_number.c b/toys/example/demo_number.c index 010320cf..42b62b51 100644 --- a/toys/example/demo_number.c +++ b/toys/example/demo_number.c @@ -2,14 +2,17 @@ * * Copyright 2015 Rob Landley <rob@landley.net> -USE_DEMO_NUMBER(NEWTOY(demo_number, "D#=3<3hdbs", TOYFLAG_BIN)) +USE_DEMO_NUMBER(NEWTOY(demo_number, "D#=3<3M#<0hcdbs", TOYFLAG_BIN)) config DEMO_NUMBER bool "demo_number" default n help - usage: demo_number [-hsbi] NUMBER... + usage: demo_number [-hsbi] [-D LEN] NUMBER... + -D output field is LEN chars + -M input units (index into bkmgtpe) + -c Comma comma down do be do down down -b Use "B" for single byte units (HR_B) -d Decimal units -h Human readable @@ -20,7 +23,7 @@ config DEMO_NUMBER #include "toys.h" GLOBALS( - long D; + long M, D; ) void demo_number_main(void) @@ -31,7 +34,7 @@ void demo_number_main(void) long long ll = atolx(*arg); if (toys.optflags) { - human_readable_long(toybuf, ll, TT.D, toys.optflags); + human_readable_long(toybuf, ll, TT.D, TT.M, toys.optflags); xputs(toybuf); } else printf("%lld\n", ll); } |