From 5a27c8095ef015e9c40709ba3186422bdf3fc069 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Tue, 29 Jan 2013 00:00:00 -0600 Subject: [PATCH] top: make field management window size error non-fatal Reference(s): http://www.freelists.org/post/procps/top-won-the-sigwinch-war,3 Signed-off-by: Jim Warner --- top/top.c | 7 ++++--- top/top_nls.c | 1 + top/top_nls.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/top/top.c b/top/top.c index 9863702d..bce176b6 100644 --- a/top/top.c +++ b/top/top.c @@ -1831,9 +1831,9 @@ static void calibrate_fields (void) { * 24 66 full xPRFX + xSUFX * 11 66 xPRFX only ( w/ room for +2 ) * 11 198 full xPRFX + xSUFX ( w/ room for +2 ) - * ( if not, the user deserves our most cryptic messages ) */ static void display_fields (int focus, int extend) { + #define mkERR { putp("\n"); putp(N_txt(XTRA_winsize_txt)); return; } #define mxCOL 6 #define yRSVD 4 #define xSUFX 22 @@ -1848,13 +1848,13 @@ static void display_fields (int focus, int extend) { static int col_sav, row_sav; i = (P_MAXPFLGS % mxCOL) ? 1 : 0; - if (rmax < i + (P_MAXPFLGS / mxCOL)) error_exit("++rows"); // nls_maybe + if (rmax < i + (P_MAXPFLGS / mxCOL)) mkERR; i = P_MAXPFLGS / rmax; if (P_MAXPFLGS % rmax) ++i; if (i > 1) { cmax /= i; xadd = 1; } if (cmax > xTOTL) cmax = xTOTL; smax = cmax - xPRFX; - if (smax < 0) error_exit("++cols"); // nls_maybe + if (smax < 0) mkERR; /* we'll go the extra distance to avoid any potential screen flicker which occurs under some terminal emulators (but it was our fault) */ @@ -1890,6 +1890,7 @@ static void display_fields (int focus, int extend) { } putp(Caps_off); + #undef mkERR #undef mxCOL #undef yRSVD #undef xSUFX diff --git a/top/top_nls.c b/top/top_nls.c index 44377931..9802269f 100644 --- a/top/top_nls.c +++ b/top/top_nls.c @@ -376,6 +376,7 @@ static void build_norm_nlstab (void) { Norm_nlstab[XTRA_fixwide_fmt] = _("width incr is %d, change to (0 default, -1 auto)"); Norm_nlstab[XTRA_warncfg_txt] = _("Overwrite existing obsolete/corrupted rcfile?"); Norm_nlstab[XTRA_sortopt_fmt] = _("unrecognized field name '%s'"); + Norm_nlstab[XTRA_winsize_txt] = _("even using field names only, window is now too small"); #ifndef INSP_OFFDEMO Norm_nlstab[YINSP_demo01_txt] = _("Open Files"); Norm_nlstab[YINSP_demo02_txt] = _("NUMA Info"); diff --git a/top/top_nls.h b/top/top_nls.h index 9289b5bd..55daafcb 100644 --- a/top/top_nls.h +++ b/top/top_nls.h @@ -80,7 +80,7 @@ enum norm_nls { THREADS_show_fmt, TIME_accumed_fmt, UNKNOWN_cmds_txt, UNKNOWN_opts_fmt, USAGE_abbrev_txt, WORD_allcpus_txt, WORD_another_txt, WORD_eachcpu_fmt, WORD_process_txt, WORD_threads_txt, WRITE_rcfile_fmt, WRONG_switch_fmt, - XTRA_fixwide_fmt, XTRA_sortopt_fmt, XTRA_warncfg_txt, + XTRA_fixwide_fmt, XTRA_sortopt_fmt, XTRA_warncfg_txt, XTRA_winsize_txt, #ifndef INSP_OFFDEMO YINSP_demo01_txt, YINSP_demo02_txt, YINSP_demo03_txt, YINSP_deqfmt_txt, YINSP_deqtyp_txt, YINSP_dstory_txt,