top: warn users if rcfile save prevents older top read
I'm about to break older top rcfile compatibility when preserving those two new toggles. And, though this has happened several times over the years, we never issued any warnings that such thing was just about to happen. So, this patch corrects the long standing shortcoming. Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
6db0d5eab6
commit
ad6917e3cf
11
top/top.c
11
top/top.c
@ -86,6 +86,7 @@ static sigset_t Sigwinch_set;
|
||||
static char Rc_name [OURPATHSZ];
|
||||
static RCF_t Rc = DEF_RCFILE;
|
||||
static int Rc_questions;
|
||||
static int Rc_compatibilty;
|
||||
|
||||
/* The run-time acquired page stuff */
|
||||
static unsigned Pg2K_shft = 0;
|
||||
@ -4027,6 +4028,10 @@ static const char *configs_file (FILE *fp, const char *name, float *delay) {
|
||||
if (Rc.zero_suppress < 0 || Rc.zero_suppress > 1)
|
||||
Rc.zero_suppress = 0;
|
||||
|
||||
// prepare to warn that older top can no longer read rcfile ...
|
||||
if (Rc.id != RCF_VERSION_ID)
|
||||
Rc_compatibilty = 1;
|
||||
|
||||
// lastly, let's process any optional glob(s) ...
|
||||
// (darn, must do osel 1st even though alphabetically 2nd)
|
||||
fbuf[0] = '\0';
|
||||
@ -5049,6 +5054,12 @@ static void write_rcfile (void) {
|
||||
return;
|
||||
Rc_questions = 0;
|
||||
}
|
||||
if (Rc_compatibilty) {
|
||||
show_pmt(N_txt(XTRA_warnold_txt));
|
||||
if ('y' != tolower(iokey(1)))
|
||||
return;
|
||||
Rc_compatibilty = 0;
|
||||
}
|
||||
if (!(fp = fopen(Rc_name, "w"))) {
|
||||
show_msg(fmtmk(N_fmt(FAIL_rc_open_fmt), Rc_name, strerror(errno)));
|
||||
return;
|
||||
|
@ -503,6 +503,7 @@ static void build_norm_nlstab (void) {
|
||||
Norm_nlstab[XTRA_vforest_fmt] = _("PID to collapse/expand [default pid = %d]");
|
||||
Norm_nlstab[XTRA_size2up_txt] = _("terminal is not wide enough");
|
||||
Norm_nlstab[XTRA_modebad_txt] = _("wrong mode, command inactive");
|
||||
Norm_nlstab[XTRA_warnold_txt] = _("saving prevents older top from reading, save anyway?");
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,7 +83,7 @@ enum norm_nls {
|
||||
WORD_eachcpu_fmt, WORD_exclude_txt, WORD_include_txt, WORD_noneone_txt,
|
||||
WORD_process_txt, WORD_threads_txt, WRITE_rcfile_fmt, WRONG_switch_fmt,
|
||||
XTRA_badflds_fmt, XTRA_fixwide_fmt, XTRA_modebad_txt, XTRA_size2up_txt,
|
||||
XTRA_vforest_fmt, XTRA_warncfg_txt, XTRA_winsize_txt,
|
||||
XTRA_vforest_fmt, XTRA_warncfg_txt, XTRA_warnold_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,
|
||||
|
Loading…
Reference in New Issue
Block a user