top: swat a bug with 3.2.8 support for field additions

This new integer based version of 'fieldscur' deviated
a bit too much from that character based logic when it
comes to ancient 3.2.8 rcfile support. This results in
an inappropriate extra field shown as the last column.

If we're truly dealing with 20 year old 3.2.8 rcfiles,
it's important the 3.3.9 extension (RCF_PLUS_H) not be
concatenated to what was read. That's because a search
for the special SUSE characters will always find a '\'
in the 26th position (after normal 3.2.8 'fieldscur').

[ for symmetry, we'll also avoid RCF_PLUS_J (3.3.17) ]

All other 'old' rcfiles are transformed without error.

Reference(s):
. Mar, 2022 - 3.2.8 support restores

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2022-03-14 00:00:00 -05:00 committed by Craig Small
parent 980dc08a5b
commit 5822210618
2 changed files with 6 additions and 6 deletions

View File

@ -3624,9 +3624,9 @@ static int cfg_xform (WIN_t *q, char *flds, const char *defs) {
q->rc.winflags |= x; q->rc.winflags |= x;
// now let's convert old top's more limited fields ... // now let's convert old top's more limited fields ...
if (CVT_FLDMAX > strlen(flds)) f = strlen(flds);
if (f >= CVT_FLDMAX)
return 1; return 1;
// here we convert old 3.2.8 top's more limited fields ...
strcpy(fields_dst, fields_src); strcpy(fields_dst, fields_src);
/* all other fields represent the 'on' state with a capitalized version /* all other fields represent the 'on' state with a capitalized version
of a particular qwerty key. for the 2 additional suse out-of-memory of a particular qwerty key. for the 2 additional suse out-of-memory
@ -3634,7 +3634,7 @@ static int cfg_xform (WIN_t *q, char *flds, const char *defs) {
in any case, we must turn them 'off' temporarily ... */ in any case, we must turn them 'off' temporarily ... */
if ((p1 = strchr(flds, '['))) *p1 = '{'; if ((p1 = strchr(flds, '['))) *p1 = '{';
if ((p2 = strchr(flds, '\\'))) *p2 = '|'; if ((p2 = strchr(flds, '\\'))) *p2 = '|';
for (i = 0; i < CVT_FLDMAX; i++) { for (i = 0; i < f; i++) {
c = flds[i]; c = flds[i];
x = tolower(c) - 'a'; x = tolower(c) - 'a';
if (x < 0 || x >= CVT_FLDMAX) if (x < 0 || x >= CVT_FLDMAX)
@ -3889,7 +3889,7 @@ static const char *configs_file (FILE *fp, const char *name, float *delay) {
SETw(w, Show_JRNUMS); SETw(w, Show_JRNUMS);
// fall through // fall through
case 'g': // from 3.3.4 thru 3.3.8 case 'g': // from 3.3.4 thru 3.3.8
scat(fbuf, RCF_PLUS_H); if (Rc.id > 'a') scat(fbuf, RCF_PLUS_H);
// fall through // fall through
case 'h': // this is release 3.3.9 case 'h': // this is release 3.3.9
w->rc.graph_cpus = w->rc.graph_mems = 0; w->rc.graph_cpus = w->rc.graph_mems = 0;
@ -3897,7 +3897,7 @@ static const char *configs_file (FILE *fp, const char *name, float *delay) {
Rc.summ_mscale = Rc.task_mscale = SK_Kb; Rc.summ_mscale = Rc.task_mscale = SK_Kb;
// fall through // fall through
case 'i': // from 3.3.10 thru 3.3.16 case 'i': // from 3.3.10 thru 3.3.16
scat(fbuf, RCF_PLUS_J); if (Rc.id > 'a') scat(fbuf, RCF_PLUS_J);
w->rc.double_up = w->rc.combine_cpus = 0; w->rc.double_up = w->rc.combine_cpus = 0;
// fall through // fall through
case 'j': // this is release 3.3.17 case 'j': // this is release 3.3.17

View File

@ -532,7 +532,7 @@ typedef struct WIN_t {
// old top fields ( 'a'-'z' ) in positions 0-25 // old top fields ( 'a'-'z' ) in positions 0-25
// other suse old top fields ( '{|' ) in positions 26-27 // other suse old top fields ( '{|' ) in positions 26-27
#define CVT_FORMER "%&*'(-0346789:;<=>?@ACDEFGML)+,./125BHIJKNOPQRSTUVWXYZ[" RCF_PLUS_H RCF_PLUS_J #define CVT_FORMER "%&*'(-0346789:;<=>?@ACDEFGML)+,./125BHIJKNOPQRSTUVWXYZ[" RCF_PLUS_H RCF_PLUS_J
#define CVT_FLDMAX 26 #define CVT_FLDMAX 28
#ifdef ORIG_TOPDEFS #ifdef ORIG_TOPDEFS
#define DEF_FIELDS { \ #define DEF_FIELDS { \