From b4fdb27a056b707181565d65866c6104073b67b1 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sat, 30 Jul 2016 00:00:00 -0500 Subject: [PATCH] top: provide for expanded potential displayable fields This commit provides for raising the total displayable fields from its current 70 to 86. It also bumps the id in an rcfile representing the version from 'i' to 'j'. The increase in number of fields will make sharing the rcfile with an older top, once it's saved, impossible. These changes are being done via a #define rather than hard coded so any such sharing will still be possible. Signed-off-by: Jim Warner --- top/top.c | 8 +++++--- top/top.h | 25 ++++++++++++++++--------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/top/top.c b/top/top.c index b476b1dc..c95985aa 100644 --- a/top/top.c +++ b/top/top.c @@ -3485,10 +3485,10 @@ static void configs_read (void) { p = fmtmk(N_fmt(RC_bad_entry_fmt), i+1, Rc_name); // note: "fieldscur=%__s" on next line should equal (PFLAGSSIZ -1) ! - if (2 != fscanf(fp, "%3s\tfieldscur=%79s\n" + if (2 != fscanf(fp, "%3s\tfieldscur=%99s\n" , w->rc.winname, w->rc.fieldscur)) goto default_or_error; -#if PFLAGSSIZ != 80 +#if PFLAGSSIZ != 100 // too bad fscanf is not as flexible with his format string as snprintf # error Hey, fix the above fscanf 'PFLAGSSIZ' dependency ! #endif @@ -3514,7 +3514,9 @@ static void configs_read (void) { // these next 2 are really global, but best documented here Rc.summ_mscale = Rc.task_mscale = SK_Kb; case 'i': // actual RCF_VERSION_ID - default: // and a future version? + scat(w->rc.fieldscur, RCF_PLUS_J); + case 'j': // and the next version + default: if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1) goto default_or_error; for (x = 0; x < EU_MAXPFLGS; ++x) diff --git a/top/top.h b/top/top.h index a53bf66c..e51aedbe 100644 --- a/top/top.h +++ b/top/top.h @@ -61,6 +61,7 @@ //#define TREE_SCANALL /* rescan array w/ forest view, avoid sort */ //#define USE_X_COLHDR /* emphasize header vs. whole col, for 'x' */ //#define VALIDATE_NLS /* validate the integrity of all nls tbls */ +//#define VER_J_RCFILE /* increase # of fields, rcfile ver to 'j' */ /*###### Notes, etc. ###################################################*/ @@ -132,7 +133,7 @@ char *strcasestr(const char *haystack, const char *needle); -- so SCREENMAX provides for all fields plus a 250+ byte command line */ #define CAPBUFSIZ 32 #define CLRBUFSIZ 64 -#define PFLAGSSIZ 80 +#define PFLAGSSIZ 100 #define SMLBUFSIZ 128 #define MEDBUFSIZ 256 #define LRGBUFSIZ 512 @@ -585,27 +586,33 @@ typedef struct WIN_t { /* Configuration files support */ #define SYS_RCFILESPEC "/etc/toprc" #define RCF_EYECATCHER "Config File (Linux processes with windows)\n" -#define RCF_VERSION_ID 'i' #define RCF_PLUS_H "\\]^_`abcdefghij" +#ifdef VER_J_RCFILE +#define RCF_PLUS_J "klmnopqrstuvwxyz" +#define RCF_VERSION_ID 'j' +#else +#define RCF_VERSION_ID 'i' +#define RCF_PLUS_J "" +#endif /* The default fields displayed and their order, if nothing is specified by the loser, oops user. note: any *contiguous* ascii sequence can serve as fieldscur characters as long as the initial value is coordinated with that specified for FLD_OFFSET - ( we're providing for up to 70 fields currently, ) + ( we're providing for up to 86 fields currently, ) ( with just one escaped value, the '\' character ) */ #define FLD_OFFSET '%' - // seq_fields "%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghij" + // seq_fields "%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz" #ifdef ORIG_TOPDEFS -#define DEF_FIELDS "¥¨³´»½ÀÄ·º¹Å&')*+,-./012568<>?ABCFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H +#define DEF_FIELDS "¥¨³´»½ÀÄ·º¹Å&')*+,-./012568<>?ABCFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H RCF_PLUS_J #else -#define DEF_FIELDS "¥&K¨³´»½@·º¹56ÄFÅ')*+,-./0128<>?ABCGHIJLMNOPQRSTUVWXYZ[" RCF_PLUS_H +#define DEF_FIELDS "¥&K¨³´»½@·º¹56ÄFÅ')*+,-./0128<>?ABCGHIJLMNOPQRSTUVWXYZ[" RCF_PLUS_H RCF_PLUS_J #endif /* Pre-configured windows/field groups */ -#define JOB_FIELDS "¥¦¹·º(³´Ä»½@<§Å)*+,-./012568>?ABCFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H -#define MEM_FIELDS "¥º»<½¾¿ÀÁMBNÃD34·Å&'()*+,-./0125689FGHIJKLOPQRSTUVWXYZ[" RCF_PLUS_H -#define USR_FIELDS "¥¦§¨ª°¹·ºÄÅ)+,-./1234568;<=>?@ABCFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H +#define JOB_FIELDS "¥¦¹·º(³´Ä»½@<§Å)*+,-./012568>?ABCFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H RCF_PLUS_J +#define MEM_FIELDS "¥º»<½¾¿ÀÁMBNÃD34·Å&'()*+,-./0125689FGHIJKLOPQRSTUVWXYZ[" RCF_PLUS_H RCF_PLUS_J +#define USR_FIELDS "¥¦§¨ª°¹·ºÄÅ)+,-./1234568;<=>?@ABCFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H RCF_PLUS_J // old top fields ( 'a'-'z' ) in positions 0-25 // other suse old top fields ( '{|' ) in positions 26-27 #define CVT_FIELDS "%&*'(-0346789:;<=>?@ACDEFGML)+,./125BHIJKNOPQRSTUVWXYZ[" -- 2.40.0