]> granicus.if.org Git - procps-ng/commitdiff
top: increase the maximum number of displayable fields
authorJim Warner <james.warner@comcast.net>
Wed, 13 Nov 2013 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@enc.com.au>
Mon, 25 Nov 2013 09:57:32 +0000 (20:57 +1100)
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>
top/top.c
top/top.h

index 301835ed11b6dc8d49d1bd31e00204accaec30b3..70eaa4a436685821ac1d9d6e8fbe8408c2e98ec5 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -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;
index e35c09ba48be4578d643399108d3a30bea6a7811..16f7668e938406428499e3eec97d2cafe34ed4d6 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -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 )