From 3a3c1604ff1c6bb682c21cfb422a7ca114e57ca7 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sun, 29 Mar 2020 00:00:00 -0500 Subject: [PATCH] top: for symmetry with 'E' add 'e' command line switch Several years after the 'e' & 'E' interactive commands were introduce to affect memory scaling, an 'E' switch was added. This was after discovering a dropped Redhat patch which provided a unique 'M' command line switch. If only for symmetry it makes sense to offer a similar command switch ('e') for the Task Area memory scaling. As was true with 'E', top's help text will show 'e' as if it were a switch without arguments in order to keep help text displayed without wrap in an 80x24 terminal. The man page, however, will show all of the arguments. Reference(s): https://gitlab.com/procps-ng/procps/-/issues/165 . 03/2017, added 'E' command line switch commit b2bd65407a2b0c3eb88bbeb05c1d8682a2bfd958 . 12/2012, added 'e' interactive command commit 21e550bc080eb30f503b2ca6fe4e9cb12b8a1616 . 12/2012, added 'E' interactive command commit bc46f67f9a63c9f43c9a697b3bfa85abf721c5da Signed-off-by: Jim Warner --- top/top.1 | 25 +++++++++++++++++++------ top/top.c | 9 +++++++++ top/top_nls.c | 2 +- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/top/top.1 b/top/top.1 index 858e4ea3..2901eaf0 100644 --- a/top/top.1 +++ b/top/top.1 @@ -25,8 +25,8 @@ .ds CI interactive command \# - Note: our 'Command Line' used in 2 places \# ( and managed to fit in an 80x24 terminal ) -.ds CL \-\fBhv\fR|\-\fBbcEHiOSs1\fR \-\fBd\fR secs \-\fBn\fR max \ -\-\fBu\fR|\fBU\fR user \-\fBp\fR pid \-\fBo\fR fld \-\fBw\fR [cols] \fR +.ds CL \-\fBhv\fR|\-\fBbcEeHiOSs1\fR \-\fBd\fR secs \-\fBn\fR max \ +\-\fBu\fR|\fBU\fR user \-\fBp\fR pids \-\fBo\fR field \-\fBw\fR [cols] \fR .ds CO command\-line option .ds CT command toggle .ds CW `current' window @@ -334,7 +334,20 @@ in Secure mode, except for root (unless the `s' \*(CO was used). For additional information on Secure mode \*(Xt 6d. SYSTEM Restrictions File. .TP 5 -\-\fBE\fR\ \ :\fIExtend-Memory-Scaling\fR as:\ \ \fB-E k\fR | \fBm\fR | \fBg\fR | \fBt\fR | \fBp\fR | \fBe\fR +\-\fBe\fR\ \ :\fIEnforce-Task-Memory-Scaling\fR as:\ \ \fB-e k\fR | \fBm\fR | \fBg\fR | \fBt\fR | \fBp\fR +Instructs \*(We to force \*(TA memory to be scaled as: +.nf + k \- kibibytes + m \- mebibytes + g \- gibibytes + t \- tebibytes + p \- pebibytes +.fi + +Later this can be changed with the `e' \*(CT. + +.TP 5 +\-\fBE\fR\ \ :\fIEnforce-Summary-Memory-Scaling\fR as:\ \ \fB-E k\fR | \fBm\fR | \fBg\fR | \fBt\fR | \fBp\fR | \fBe\fR Instructs \*(We to force \*(SA memory to be scaled as: .nf k \- kibibytes @@ -1207,7 +1220,7 @@ If at any time you wish to know the current delay time, simply ask for help and view the system summary on the second line. .TP 7 -\ \ \ \fBE\fR\ \ :\fIExtend-Memory-Scale\fR in Summary Area +\ \ \ \fBE\fR\ \ :\fIEnforce-Summary-Memory-Scale\fR in Summary Area With this command you can cycle through the available \*(SA memory scaling which ranges from KiB (kibibytes or 1,024 bytes) through EiB (exbibytes or 1,152,921,504,606,846,976 bytes). @@ -1217,8 +1230,8 @@ means that \*(We was forced to truncate some portion of that number. By raising the scaling factor, such truncation can be avoided. .TP 7 -\ \ \ \fBe\fR\ \ :\fIExtend-Memory-Scale\fR in Task Windows -With this command you can cycle through the available \*(TW memory scaling +\ \ \ \fBe\fR\ \ :\fIEnforce-Task-Memory-Scale\fR in Task Area +With this command you can cycle through the available \*(TA memory scaling which ranges from KiB (kibibytes or 1,024 bytes) through PiB (pebibytes or 1,125,899,906,842,624 bytes). diff --git a/top/top.c b/top/top.c index 2f361818..b9337a17 100644 --- a/top/top.c +++ b/top/top.c @@ -3767,6 +3767,15 @@ static void parse_args (char **args) { if (0 > tmp_delay) error_exit(N_txt(DELAY_badarg_txt)); break; + case 'e': + { const char *get = "kmgtp", *got; + if (cp[1]) cp++; + else if (*args) cp = *args++; + else error_exit(fmtmk(N_fmt(MISSING_args_fmt), ch)); + if (!(got = strchr(get, tolower(*cp)))) + error_exit(fmtmk(N_fmt(BAD_memscale_fmt), *cp)); + Rc.task_mscale = (int)(got - get); + } goto bump_cp; case 'E': { const char *get = "kmgtpe", *got; if (cp[1]) cp++; diff --git a/top/top_nls.c b/top/top_nls.c index 8f87dffb..d5d56357 100644 --- a/top/top_nls.c +++ b/top/top_nls.c @@ -354,7 +354,7 @@ static void build_norm_nlstab (void) { Norm_nlstab[OFF_one_word_txt] = _("Off"); /* Translation Hint: Only the following words should be translated . secs (seconds), max (maximum), user, field, cols (columns)*/ - Norm_nlstab[USAGE_abbrev_txt] = _(" -hv | -bcEHiOSs1 -d secs -n max -u|U user -p pid(s) -o field -w [cols]"); + Norm_nlstab[USAGE_abbrev_txt] = _(" -hv | -bcEeHiOSs1 -d secs -n max -u|U user -p pid(s) -o field -w [cols]"); Norm_nlstab[FOREST_modes_fmt] = _("Forest mode %s"); Norm_nlstab[FAIL_tty_get_txt] = _("failed tty get"); Norm_nlstab[FAIL_tty_set_fmt] = _("failed tty set: %s");