top: increase the maximum number of displayable fields

The recent addition of namespaces, combined with those
potential suse out-of-memory fields, means that we are
close to the maximum number of fields poor ol' top can
display. Imagine, the really old top was limited to 26
fields (28 with the suse hack) and this top had neared
the version 'g' rcfile limits which were a healthy 55.

This patch adds another 15 fields to the maximum while
making it even easier to increase in the future. Also,
top still silently accommodates older config files all
the way back to the original pre-ng version top-3.2.8!

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2013-11-13 00:00:00 -06:00 committed by Craig Small
parent 675200b20b
commit af4e6533ba
2 changed files with 17 additions and 16 deletions

View File

@ -3351,7 +3351,6 @@ static int config_cvt (WIN_t *q) {
} }
} }
q->rc.winflags |= x; q->rc.winflags |= x;
SETw(q, Show_JRNUMS);
// now let's convert old top's more limited fields... // now let's convert old top's more limited fields...
j = strlen(q->rc.fieldscur); j = strlen(q->rc.fieldscur);
@ -3447,10 +3446,10 @@ static void configs_read (void) {
p = fmtmk(N_fmt(RC_bad_entry_fmt), i+1, Rc_name); p = fmtmk(N_fmt(RC_bad_entry_fmt), i+1, Rc_name);
// note: "fieldscur=%__s" on next line should equal PFLAGSSIZ ! // note: "fieldscur=%__s" on next line should equal PFLAGSSIZ !
if (2 != fscanf(fp, "%3s\tfieldscur=%64s\n" if (2 != fscanf(fp, "%3s\tfieldscur=%80s\n"
, w->rc.winname, w->rc.fieldscur)) , w->rc.winname, w->rc.fieldscur))
goto default_or_error; goto default_or_error;
#if PFLAGSSIZ > 64 #if PFLAGSSIZ > 80
// too bad fscanf is not as flexible with his format string as snprintf // too bad fscanf is not as flexible with his format string as snprintf
# error Hey, fix the above fscanf 'PFLAGSSIZ' dependency ! # error Hey, fix the above fscanf 'PFLAGSSIZ' dependency !
#endif #endif
@ -3465,11 +3464,12 @@ static void configs_read (void) {
switch (Rc.id) { switch (Rc.id) {
case 'a': // 3.2.8 (former procps) case 'a': // 3.2.8 (former procps)
if (config_cvt(w)) if (config_cvt(w))
goto default_or_error; goto default_or_error; // fall through !
break;
case 'f': // 3.3.0 thru 3.3.3 (procps-ng) case 'f': // 3.3.0 thru 3.3.3 (procps-ng)
SETw(w, Show_JRNUMS); // fall through ! SETw(w, Show_JRNUMS); // fall through !
case 'g': // current RCF_VERSION_ID case 'g': // 3.3.4 thru 3.3.8
scat(w->rc.fieldscur, RCF_PLUS_H); // fall through !
case 'h': // current RCF_VERSION_ID
default: // and future versions? default: // and future versions?
if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1) if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1)
goto default_or_error; goto default_or_error;

View File

@ -123,7 +123,7 @@ char *strcasestr(const char *haystack, const char *needle);
-- so SCREENMAX provides for all fields plus a 250+ byte command line */ -- so SCREENMAX provides for all fields plus a 250+ byte command line */
#define CAPBUFSIZ 32 #define CAPBUFSIZ 32
#define CLRBUFSIZ 64 #define CLRBUFSIZ 64
#define PFLAGSSIZ 64 #define PFLAGSSIZ 80
#define SMLBUFSIZ 128 #define SMLBUFSIZ 128
#define MEDBUFSIZ 256 #define MEDBUFSIZ 256
#define LRGBUFSIZ 512 #define LRGBUFSIZ 512
@ -565,22 +565,23 @@ typedef struct WIN_t {
/* Configuration files support */ /* Configuration files support */
#define SYS_RCFILESPEC "/etc/toprc" #define SYS_RCFILESPEC "/etc/toprc"
#define RCF_EYECATCHER "Config File (Linux processes with windows)\n" #define RCF_EYECATCHER "Config File (Linux processes with windows)\n"
#define RCF_VERSION_ID 'g' #define RCF_VERSION_ID 'h'
#define RCF_PLUS_H "\\]^_`abcdefghij"
/* The default fields displayed and their order, if nothing is /* The default fields displayed and their order, if nothing is
specified by the loser, oops user. specified by the loser, oops user.
note: any *contiguous* ascii sequence can serve as fieldscur note: any *contiguous* ascii sequence can serve as fieldscur
characters as long as the initial value is coordinated characters as long as the initial value is coordinated
with that specified for FLD_OFFSET with that specified for FLD_OFFSET
( we're providing for up to 55 fields initially, ) ( we're providing for up to 70 fields currently, )
( with values chosen to avoid the need to escape ) */ ( with just one escaped value, the '\' character ) */
#define FLD_OFFSET '%' #define FLD_OFFSET '%'
// seq_fields "%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[" // seq_fields "%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghij"
#define DEF_FIELDS "¥¨³´»½ÀÄ·º¹Å&')*+,-./012568<>?ABCFGHIJKLMNOPQRSTUVWXYZ[" #define DEF_FIELDS "¥¨³´»½ÀÄ·º¹Å&')*+,-./012568<>?ABCFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H
/* Pre-configured windows/field groups */ /* Pre-configured windows/field groups */
#define JOB_FIELDS "¥¦¹·º³´Ä»¼½§Å()*+,-./012568>?@ABCFGHIJKLMNOPQRSTUVWXYZ[" #define JOB_FIELDS "¥¦¹·º³´Ä»¼½§Å()*+,-./012568>?@ABCFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H
#define MEM_FIELDS "¥º»¼½¾¿ÀÁÃij´·Å&'()*+,-./0125689BFGHIJKLMNOPQRSTUVWXYZ[" #define MEM_FIELDS "¥º»¼½¾¿ÀÁÃij´·Å&'()*+,-./0125689BFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H
#define USR_FIELDS "¥¦§¨ª°¹·ºÄÅ)+,-./1234568;<=>?@ABCFGHIJKLMNOPQRSTUVWXYZ[" #define USR_FIELDS "¥¦§¨ª°¹·ºÄÅ)+,-./1234568;<=>?@ABCFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H
#ifdef OOMEM_ENABLE #ifdef OOMEM_ENABLE
// the suse old top fields ( 'a'-'z' + '{|' ) in positions 0-27 // the suse old top fields ( 'a'-'z' + '{|' ) in positions 0-27
// ( the extra chars above represent the 'off' state ) // ( the extra chars above represent the 'off' state )