From ec5e6e12ee6d7047ab013f3a2826abdb52666ea0 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 4 Sep 2020 01:04:43 -0500 Subject: Add commas to top display, and adjust memory units to megabytes if >10G RAM. --- toys/example/demo_number.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'toys/example') 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 -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); } -- cgit v1.2.3