]> granicus.if.org Git - procps-ng/commitdiff
top: circumvent an ncurses version 5.9.20121017 glitch
authorJim Warner <james.warner@comcast.net>
Mon, 7 Jan 2013 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@enc.com.au>
Wed, 23 Jan 2013 10:23:36 +0000 (21:23 +1100)
Some testing under a new distro revealed what appeared
to be a broken top Inspect request. When the selection
was made, the resulting output was scrambled/scrunched
at the bottom of the screen (as if ^J's were missing).

This anomaly surfaced under Fedora-18 which happens to
use the above ncurses version. The bug was not present
in version 5.9.20120714 (available with openSUSE 12.2)
or the more widely available version of: 5.9.20110404.

It has now been confirmed that this problem originated
in version 5.9.20120825. It was then that buffering of
output was changed from stdio to some internal ncurses
scheme so as to avoid problems with its SIGTSTP logic.

Thanks to a very prompt response from Thomas E. Dickey
we also learned that contrary to the documentation the
putp logic does not call putchar internally. Thus, the
single putchar that Inspect was employing was actually
mixing 2 different buffering schemes: ncurses & stdio.

Thus, from now on we'll use putp() exclusively and try
to achieve single char output as efficiently as we can
while meeting that putp() string argument requirement.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
https://bugzilla.redhat.com/892674

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c

index 92ea0f37e9ca90c283dd0661be78400d9e6e5160..3f3fcdb0df081fada251ea0fdf915a77814df31d 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -2645,7 +2645,8 @@ static inline void insp_make_row (int col, int row) {
  #define mkUNP { if ((to += 4) <= Screen_cols) \
     PUTT("%s<%02X>", (!hicap) ? Curwin->capclr_msg : "", uch); hicap = 1; }
 #endif
- #define mkSTD { capNO; if (++to <= Screen_cols) putchar(uch); }
+ #define mkSTD { capNO; if (++to <= Screen_cols) { static char _str[2]; \
+    _str[0] = uch; putp(_str); } }
    char tline[SCREENMAX];
    int fr, to, ofs;
    int hicap = 0;