]> granicus.if.org Git - procps-ng/commitdiff
top: make compilation possible under netbsd-curses too
authorJim Warner <james.warner@comcast.net>
Sat, 16 Jul 2016 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Sat, 16 Jul 2016 23:31:57 +0000 (09:31 +1000)
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>
top/top.c

index da70ff0d5170cd93815d4c537ffd445ad84e8436..7375955ad6d3ed1f328379f271cc898b50d6ee2c 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -486,6 +486,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!
@@ -528,15 +531,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
@@ -554,6 +557,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