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 <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2013-01-29 00:00:00 -06:00 committed by Craig Small
parent f3a87cf634
commit 5a27c8095e
3 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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");

View File

@ -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,