top: make compilation possible under netbsd-curses too

Whoa, I had never considered an alternative to ncurses
until the issue referenced below was raised. Thus, I'm
surprised to find that 'tparm' was the only impediment
to ultimately utilizing this alternate curses library.

And, while we could have substituted that non-standard
'tiparm' with only 2 arguments, we'll utilize the full
parms compliment in the spirit of that original patch.

Frankly, the task of developing an alternative library
to that ncurses implementation really boggles my mind.

Congratulations to rofl0r, whoever that masked man is.

Reference(s):
. issue raised
https://gitlab.com/procps-ng/procps/issues/38
. netbsd-curses home
https://github.com/sabotage-linux/netbsd-curses

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2016-07-16 00:00:00 -05:00 committed by Craig Small
parent bf7e728098
commit 63f8c16fa4

View File

@ -661,6 +661,9 @@ static void capsmk (WIN_t *q) {
/* macro to test if a basic (non-color) capability is valid
thanks: Floyd Davidson <floyd@ptialaska.net> */
#define tIF(s) s ? s : ""
/* macro to make compatible with netbsd-curses too
thanks: rofl0r <retnyg@gmx.net> */
#define tPM(a,b) tparm(a, b, 0, 0, 0, 0, 0, 0, 0, 0)
static int capsdone = 0;
// we must NOT disturb our 'empty' terminfo strings!
@ -703,15 +706,15 @@ static void capsmk (WIN_t *q) {
the job's done until he/she/it has a change-of-heart */
STRLCPY(q->cap_bold, CHKw(q, View_NOBOLD) ? Cap_norm : tIF(enter_bold_mode))
if (CHKw(q, Show_COLORS) && max_colors > 0) {
STRLCPY(q->capclr_sum, tparm(set_a_foreground, q->rc.summclr))
STRLCPY(q->capclr_sum, tPM(set_a_foreground, q->rc.summclr))
snprintf(q->capclr_msg, sizeof(q->capclr_msg), "%s%s"
, tparm(set_a_foreground, q->rc.msgsclr), Cap_reverse);
, tPM(set_a_foreground, q->rc.msgsclr), Cap_reverse);
snprintf(q->capclr_pmt, sizeof(q->capclr_pmt), "%s%s"
, tparm(set_a_foreground, q->rc.msgsclr), q->cap_bold);
, tPM(set_a_foreground, q->rc.msgsclr), q->cap_bold);
snprintf(q->capclr_hdr, sizeof(q->capclr_hdr), "%s%s"
, tparm(set_a_foreground, q->rc.headclr), Cap_reverse);
, tPM(set_a_foreground, q->rc.headclr), Cap_reverse);
snprintf(q->capclr_rownorm, sizeof(q->capclr_rownorm), "%s%s"
, Caps_off, tparm(set_a_foreground, q->rc.taskclr));
, Caps_off, tPM(set_a_foreground, q->rc.taskclr));
} else {
q->capclr_sum[0] = '\0';
#ifdef USE_X_COLHDR
@ -729,6 +732,7 @@ static void capsmk (WIN_t *q) {
snprintf(q->capclr_rowhigh, sizeof(q->capclr_rowhigh), "%s%s"
, q->capclr_rownorm, CHKw(q, Show_HIBOLD) ? q->cap_bold : Cap_reverse);
#undef tIF
#undef tPM
} // end: capsmk