top: just miscellaneous tweaks to code and/or comments

This patch represents the following minor adjustments:

. the official PROCPS_MEMINFO_VAL macro has become the
basis for our own abbreviated MEM_VAL derivative macro
just like was done for all the other newlib interfaces

. it felt like time to change those forest_?? function
names while maintaining their special relationships to
one another (alphabetic, with each 1 longer than prev)

. and some whitespace was altered and some lines added

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2016-06-01 00:00:00 -05:00 committed by Craig Small
parent 2aaae6f29b
commit 0196a4e350
2 changed files with 17 additions and 16 deletions

View File

@ -208,7 +208,7 @@ enum Rel_memitems {
mem_FRE, mem_USE, mem_TOT, mem_QUE, mem_BUF, mem_AVL, mem_FRE, mem_USE, mem_TOT, mem_QUE, mem_BUF, mem_AVL,
swp_TOT, swp_FRE, swp_USE }; swp_TOT, swp_FRE, swp_USE };
// mem stack results extractor macro, where e=rel enum // mem stack results extractor macro, where e=rel enum
#define MEM_VAL(e) Mem_stack->head[e].result.ul_int #define MEM_VAL(e) PROCPS_MEMINFO_VAL(e, ul_int, Mem_stack)
// --- <proc/pids.h> -------------------------------------------------- // --- <proc/pids.h> --------------------------------------------------
static struct procps_pidsinfo *Pids_ctx; static struct procps_pidsinfo *Pids_ctx;
static int Pids_itms_cur; // 'current' max (<= Fieldstab) static int Pids_itms_cur; // 'current' max (<= Fieldstab)
@ -2776,6 +2776,7 @@ signify_that:
#undef mkSEL #undef mkSEL
} // end: inspection_utility } // end: inspection_utility
#undef INSP_MKSL #undef INSP_MKSL
#undef INSP_RLEN #undef INSP_RLEN
#undef INSP_BUSY #undef INSP_BUSY
@ -4428,17 +4429,17 @@ static void keys_xtra (int ch) {
/* /*
* We try to keep most existing code unaware of our activities * We try to keep most existing code unaware of our activities
* ( plus, maintain alphabetical order with carefully chosen ) * ( plus, maintain alphabetical order with carefully chosen )
* ( function names like such: forest_b, forest_c & forest_d ) * ( function names like such: forest_a, forest_b & forest_c )
* ( each with exactly one letter more than its predecessor! ) */ * ( each with exactly one letter more than its predecessor! ) */
static struct pids_stack **Seed_ppt; // temporary win ppt pointer static struct pids_stack **Seed_ppt; // temporary win ppt pointer
static struct pids_stack **Tree_ppt; // forest_create will resize static struct pids_stack **Tree_ppt; // forest_begin resizes this
static int Tree_idx; // frame_make resets to zero static int Tree_idx; // frame_make resets to zero
/* /*
* This little recursive guy is the real forest view workhorse. * This little recursive guy is the real forest view workhorse.
* He fills in the Tree_ppt array and also sets the child indent * He fills in the Tree_ppt array and also sets the child indent
* level which is stored in an 'extra' result struct as a u_int. */ * level which is stored in an 'extra' result struct as a u_int. */
static void forest_begin (const int self, int level) { static void forest_adds (const int self, int level) {
// tailored 'results stack value' extractor macros // tailored 'results stack value' extractor macros
#define rSv(E,X) PID_VAL(E, s_int, Seed_ppt[X]) #define rSv(E,X) PID_VAL(E, s_int, Seed_ppt[X])
#define rLevel PID_VAL(eu_XTRA, u_int, Tree_ppt[Tree_idx]) #define rLevel PID_VAL(eu_XTRA, u_int, Tree_ppt[Tree_idx])
@ -4457,12 +4458,12 @@ static void forest_begin (const int self, int level) {
#endif #endif
if (rSv(EU_PID, self) == rSv(EU_TGD, i) if (rSv(EU_PID, self) == rSv(EU_TGD, i)
|| (rSv(EU_PID, self) == rSv(EU_PPD, i) && rSv(EU_PID, i) == rSv(EU_TGD, i))) || (rSv(EU_PID, self) == rSv(EU_PPD, i) && rSv(EU_PID, i) == rSv(EU_TGD, i)))
forest_begin(i, level + 1); // got one child any others? forest_adds(i, level + 1); // got one child any others?
} }
} }
#undef rSv #undef rSv
#undef rLevel #undef rLevel
} // end: forest_begin } // end: forest_adds
/* /*
@ -4470,7 +4471,7 @@ static void forest_begin (const int self, int level) {
* a forest display in the designated window. Upon completion, * a forest display in the designated window. Upon completion,
* he'll replace the original window ppt with our specially * he'll replace the original window ppt with our specially
* ordered forest version. */ * ordered forest version. */
static void forest_create (WIN_t *q) { static void forest_begin (WIN_t *q) {
// tailored 'results stack value' extractor macro // tailored 'results stack value' extractor macro
#define rLevel PID_VAL(eu_XTRA, u_int, Seed_ppt[i]) #define rLevel PID_VAL(eu_XTRA, u_int, Seed_ppt[i])
static int hwmsav; static int hwmsav;
@ -4489,17 +4490,17 @@ static void forest_create (WIN_t *q) {
#endif #endif
for (i = 0; i < PIDSmaxt; i++) // avoid any hidepid distortions for (i = 0; i < PIDSmaxt; i++) // avoid any hidepid distortions
if (!rLevel) // identify real or pretend trees if (!rLevel) // identify real or pretend trees
forest_begin(i, 1); // add as parent plus its children forest_adds(i, 1); // add as parent plus its children
} }
memcpy(Seed_ppt, Tree_ppt, sizeof(void*) * PIDSmaxt); memcpy(Seed_ppt, Tree_ppt, sizeof(void*) * PIDSmaxt);
#undef rLevel #undef rLevel
} // end: forest_create } // end: forest_begin
/* /*
* This guy adds the artwork to either a 'cmd' or 'cmdline' * This guy adds the artwork to either a 'cmd' or 'cmdline'
* when in forest view mode, otherwise he just returns 'em. */ * when in forest view mode, otherwise he just returns 'em. */
static inline const char *forest_display (const WIN_t *q, struct pids_stack *p) { static inline const char *forest_colour (const WIN_t *q, struct pids_stack *p) {
// tailored 'results stack value' extractor macros // tailored 'results stack value' extractor macros
#define rSv(E) PID_VAL(E, str, p) #define rSv(E) PID_VAL(E, str, p)
#define rLevel PID_VAL(eu_XTRA, u_int, p) #define rLevel PID_VAL(eu_XTRA, u_int, p)
@ -4516,7 +4517,7 @@ static inline const char *forest_display (const WIN_t *q, struct pids_stack *p)
return buf; return buf;
#undef rSv #undef rSv
#undef rLevel #undef rLevel
} // end: forest_display } // end: forest_colour
/*###### Main Screen routines ##########################################*/ /*###### Main Screen routines ##########################################*/
@ -4991,7 +4992,7 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) {
break; break;
/* str, make_str with varialbe width + additional decoration */ /* str, make_str with varialbe width + additional decoration */
case EU_CMD: case EU_CMD:
makeVAR(forest_display(q, p)); makeVAR(forest_colour(q, p));
break; break;
default: // keep gcc happy default: // keep gcc happy
continue; continue;
@ -5050,7 +5051,7 @@ static int window_show (WIN_t *q, int wmax) {
PUFF("\n%s%s%s", q->capclr_hdr, q->columnhdr, Caps_endline); PUFF("\n%s%s%s", q->capclr_hdr, q->columnhdr, Caps_endline);
if (CHKw(q, Show_FOREST)) if (CHKw(q, Show_FOREST))
forest_create(q); forest_begin(q);
else { else {
enum pids_item item = Fieldstab[q->rc.sortindx].item; enum pids_item item = Fieldstab[q->rc.sortindx].item;
if (item == PROCPS_PIDS_CMD && CHKw(q, Show_CMDLIN)) if (item == PROCPS_PIDS_CMD && CHKw(q, Show_CMDLIN))

View File

@ -634,9 +634,9 @@ typedef struct WIN_t {
//atic void keys_window (int ch); //atic void keys_window (int ch);
//atic void keys_xtra (int ch); //atic void keys_xtra (int ch);
/*------ Forest View support -------------------------------------------*/ /*------ Forest View support -------------------------------------------*/
//atic void forest_begin (const int self, int level); //atic void forest_adds (const int self, int level);
//atic void forest_create (WIN_t *q); //atic void forest_begin (WIN_t *q);
//atic inline const char *forest_display (const WIN_t *q, struct pids_stack *p); //atic inline const char *forest_colour (const WIN_t *q, struct pids_stack *p);
/*------ Main Screen routines ------------------------------------------*/ /*------ Main Screen routines ------------------------------------------*/
//atic void do_key (int ch); //atic void do_key (int ch);
//atic void summary_hlp (struct stat_stack *this, const char *pfx); //atic void summary_hlp (struct stat_stack *this, const char *pfx);