fix #H4060 - sysconf is re-read if no config file
Config file handling remembers the name of the last config file read in order for options processing to use it in messages, but it was also reused as default config file name if user-supplied config file name failed access() test. So the SYSCF file became the default user config file after it was used. The config file handling was a real mess. This patch fixes it for Unix but there is a lot of scope for typos in the changes for other platforms. Testing is needed.
This commit is contained in:
@@ -420,6 +420,8 @@ static struct Comp_Opt {
|
||||
|
||||
#else /* use rest of file */
|
||||
|
||||
extern char configfile[]; /* for messages */
|
||||
|
||||
extern struct symparse loadsyms[];
|
||||
static boolean need_redraw; /* for doset() */
|
||||
|
||||
@@ -917,10 +919,10 @@ rejectoption(optname)
|
||||
const char *optname;
|
||||
{
|
||||
#ifdef MICRO
|
||||
pline("\"%s\" settable only from %s.", optname, lastconfigfile);
|
||||
pline("\"%s\" settable only from %s.", optname, configfile);
|
||||
#else
|
||||
pline("%s can be set only from NETHACKOPTIONS or %s.", optname,
|
||||
lastconfigfile);
|
||||
configfile);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -941,7 +943,7 @@ const char *opts;
|
||||
#endif
|
||||
|
||||
if (from_file)
|
||||
raw_printf("Bad syntax in OPTIONS in %s: %s%s.\n", lastconfigfile,
|
||||
raw_printf("Bad syntax in OPTIONS in %s: %s%s.\n", configfile,
|
||||
#ifdef WIN32
|
||||
"\n",
|
||||
#else
|
||||
@@ -5318,7 +5320,7 @@ option_help()
|
||||
winid datawin;
|
||||
|
||||
datawin = create_nhwindow(NHW_TEXT);
|
||||
Sprintf(buf, "Set options as OPTIONS=<options> in %s", lastconfigfile);
|
||||
Sprintf(buf, "Set options as OPTIONS=<options> in %s", configfile);
|
||||
opt_intro[CONFIG_SLOT] = (const char *) buf;
|
||||
for (i = 0; opt_intro[i]; i++)
|
||||
putstr(datawin, 0, opt_intro[i]);
|
||||
|
||||
Reference in New Issue
Block a user