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;
SETw(q, Show_JRNUMS);
// now let's convert old top's more limited fields...
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);
// 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))
goto default_or_error;
#if PFLAGSSIZ > 64
#if PFLAGSSIZ > 80
// too bad fscanf is not as flexible with his format string as snprintf
# error Hey, fix the above fscanf 'PFLAGSSIZ' dependency !
#endif
@ -3465,11 +3464,12 @@ static void configs_read (void) {
switch (Rc.id) {
case 'a': // 3.2.8 (former procps)
if (config_cvt(w))
goto default_or_error;
break;
goto default_or_error; // fall through !
case 'f': // 3.3.0 thru 3.3.3 (procps-ng)
SETw(w, Show_JRNUMS); // fall through !
case 'g': // current RCF_VERSION_ID
SETw(w, Show_JRNUMS); // fall through !
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?
if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1)
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 */
#define CAPBUFSIZ 32
#define CLRBUFSIZ 64
#define PFLAGSSIZ 64
#define PFLAGSSIZ 80
#define SMLBUFSIZ 128
#define MEDBUFSIZ 256
#define LRGBUFSIZ 512
@ -565,22 +565,23 @@ 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 'g'
#define RCF_VERSION_ID 'h'
#define RCF_PLUS_H "\\]^_`abcdefghij"
/* 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 55 fields initially, )
( with values chosen to avoid the need to escape ) */
( we're providing for up to 70 fields currently, )
( with just one escaped value, the '\' character ) */
#define FLD_OFFSET '%'
// seq_fields "%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ["
#define DEF_FIELDS "¥¨³´»½ÀÄ·º¹Å&')*+,-./012568<>?ABCFGHIJKLMNOPQRSTUVWXYZ["
// seq_fields "%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghij"
#define DEF_FIELDS "¥¨³´»½ÀÄ·º¹Å&')*+,-./012568<>?ABCFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H
/* Pre-configured windows/field groups */
#define JOB_FIELDS "¥¦¹·º³´Ä»¼½§Å()*+,-./012568>?@ABCFGHIJKLMNOPQRSTUVWXYZ["
#define MEM_FIELDS "¥º»¼½¾¿ÀÁÃij´·Å&'()*+,-./0125689BFGHIJKLMNOPQRSTUVWXYZ["
#define USR_FIELDS "¥¦§¨ª°¹·ºÄÅ)+,-./1234568;<=>?@ABCFGHIJKLMNOPQRSTUVWXYZ["
#define JOB_FIELDS "¥¦¹·º³´Ä»¼½§Å()*+,-./012568>?@ABCFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H
#define MEM_FIELDS "¥º»¼½¾¿ÀÁÃij´·Å&'()*+,-./0125689BFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H
#define USR_FIELDS "¥¦§¨ª°¹·ºÄÅ)+,-./1234568;<=>?@ABCFGHIJKLMNOPQRSTUVWXYZ[" RCF_PLUS_H
#ifdef OOMEM_ENABLE
// the suse old top fields ( 'a'-'z' + '{|' ) in positions 0-27
// ( the extra chars above represent the 'off' state )