From 7060f9ab3ac212dc9c0f5fca7d5b27d28d10bf64 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Mon, 7 Jan 2013 00:00:00 -0600 Subject: [PATCH] top: circumvent an ncurses version 5.9.20121017 glitch 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 --- top/top.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/top/top.c b/top/top.c index 92ea0f37..3f3fcdb0 100644 --- 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;