feedback about config file name on MacOS
When hunting for player's run-time config file under MacOS/OSX, nethack looks for .nethackrc (or $HOME/.nethackrc), then if not found it looks for "$HOME/Library/Preferences/NetHack Defaults", and finally for "$HOME/Library/Preferences/NetHack Defaults.txt". When none of those exists, the last choice has been being left in configfile[] and can get used in messages. The menu for entering the tutorial includes a tip about setting OPTIONS=!tutorial in the config file, but it was showing the third choice rather than the first when none of them are found. Change config file name setup to remember the first name rather than the last when it represents a non-existant/not-yet-existent file, so that the tip recommnends the standard Unix name rather than the Mac-specific one.
This commit is contained in:
24
src/files.c
24
src/files.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 files.c $NHDT-Date: 1737346561 2025/01/19 20:16:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.416 $ */
|
||||
/* NetHack 3.7 files.c $NHDT-Date: 1740532826 2025/02/25 17:20:26 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.417 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Derek S. Ray, 2015. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -2291,18 +2291,28 @@ fopen_config_file(const char *filename, int src)
|
||||
set_configfile_name(tmp_config);
|
||||
if ((fp = fopen(configfile, "r")) != (FILE *) 0)
|
||||
return fp;
|
||||
#if defined(__APPLE__) /* UNIX+__APPLE__ => MacOSX */
|
||||
#if defined(__APPLE__) /* UNIX+__APPLE__ => OSX || MacOS */
|
||||
/* try an alternative */
|
||||
if (envp) {
|
||||
/* keep 'tmp_config' intact here; if alternates fail, use it to
|
||||
restore configfile[] to its preferred setting (".nethackrc") */
|
||||
char alt_config[sizeof tmp_config];
|
||||
|
||||
/* OSX-style configuration settings */
|
||||
Sprintf(tmp_config, "%s/%s", envp,
|
||||
"Library/Preferences/NetHack Defaults");
|
||||
set_configfile_name(tmp_config);
|
||||
Snprintf(alt_config, sizeof alt_config, "%s/%s", envp,
|
||||
"Library/Preferences/NetHack Defaults");
|
||||
set_configfile_name(alt_config);
|
||||
if ((fp = fopen(configfile, "r")) != (FILE *) 0)
|
||||
return fp;
|
||||
/* may be easier for user to edit if filename has '.txt' suffix */
|
||||
Sprintf(tmp_config, "%s/%s", envp,
|
||||
"Library/Preferences/NetHack Defaults.txt");
|
||||
Snprintf(alt_config, sizeof alt_config, "%s/%s", envp,
|
||||
"Library/Preferences/NetHack Defaults.txt");
|
||||
set_configfile_name(alt_config);
|
||||
if ((fp = fopen(configfile, "r")) != (FILE *) 0)
|
||||
return fp;
|
||||
/* couldn't open either of the alternate names; for use in
|
||||
messages, put 'configfile' back to the normal value rather than
|
||||
leaving it set to last alternate; retry open() to reset 'errno' */
|
||||
set_configfile_name(tmp_config);
|
||||
if ((fp = fopen(configfile, "r")) != (FILE *) 0)
|
||||
return fp;
|
||||
|
||||
Reference in New Issue
Block a user