check %USERPROFILE% first for config on win32
USERPROFILE is always set on a Win32 box, and doesn't conflict in the case of an MSDOS box. so look for our config file in this order: 1) USERPROFILE\defaults.nh 2) CWD\defaults.nh 3) USERPROFILE\NetHack.cnf 4) CWD\NetHack.cnf after that, the settings inside can take over (PREFIXES_IN_USE).
This commit is contained in:
37
src/files.c
37
src/files.c
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.5 files.c $NHDT-Date: 1425081976 2015/02/28 00:06:16 $ $NHDT-Branch: master $:$NHDT-Revision: 1.127 $ */
|
/* NetHack 3.5 files.c $NHDT-Date: 1426545233 2015/03/16 22:33:53 $ $NHDT-Branch: derek-farming $:$NHDT-Revision: 1.133 $ */
|
||||||
/* NetHack 3.5 files.c $Date: 2012/03/10 02:49:08 $ $Revision: 1.124 $ */
|
/* NetHack 3.5 files.c $Date: 2012/03/10 02:49:08 $ $Revision: 1.124 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -1833,7 +1833,7 @@ const char *filename;
|
|||||||
int src;
|
int src;
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
#if defined(UNIX) || defined(VMS)
|
#if defined(UNIX) || defined(VMS) || defined(WIN32) || defined(MSDOS)
|
||||||
char tmp_config[BUFSZ];
|
char tmp_config[BUFSZ];
|
||||||
char *envp;
|
char *envp;
|
||||||
#endif
|
#endif
|
||||||
@@ -1872,13 +1872,38 @@ int src;
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MICRO) || defined(MAC) || defined(__BEOS__) || defined(WIN32)
|
#if defined(MICRO) || defined(MAC) || defined(__BEOS__) || defined(WIN32)
|
||||||
if ((fp = fopenp(fqname(configfile, CONFIGPREFIX, 0), "r"))
|
# if defined(WIN32) || defined(MSDOS)
|
||||||
!= (FILE *)0)
|
/* user's home directory should be where we look first here, too */
|
||||||
|
envp = nh_getenv("USERPROFILE");
|
||||||
|
# endif
|
||||||
|
# ifdef WIN32
|
||||||
|
if (!envp) {
|
||||||
|
Strcpy(tmp_config, configfile);
|
||||||
|
} else {
|
||||||
|
Sprintf(tmp_config, "%s\\%s", envp, configfile);
|
||||||
|
}
|
||||||
|
/* try the home directory first, then the output of fqname() will
|
||||||
|
* pick up the current dir */
|
||||||
|
if ((fp = fopenp(tmp_config, "r")) != (FILE *)0)
|
||||||
|
return(fp);
|
||||||
|
if ((fp = fopenp(fqname(configfile, CONFIGPREFIX, 0), "r")) != (FILE *)0)
|
||||||
return(fp);
|
return(fp);
|
||||||
|
# else
|
||||||
|
if ((fp = fopenp(fqname(configfile, CONFIGPREFIX, 0), "r")) != (FILE *)0)
|
||||||
|
return(fp);
|
||||||
|
# endif
|
||||||
# ifdef MSDOS
|
# ifdef MSDOS
|
||||||
else if ((fp = fopenp(fqname(backward_compat_configfile,
|
else {
|
||||||
CONFIGPREFIX, 0), "r")) != (FILE *)0)
|
if (!envp) {
|
||||||
|
Strcpy(tmp_config, backward_compat_configfile);
|
||||||
|
} else {
|
||||||
|
Sprintf(tmp_config, "%s\\%s", envp, backward_compat_configfile);
|
||||||
|
}
|
||||||
|
if ((fp = fopenp(tmp_config, "r")) != (FILE *)0)
|
||||||
return(fp);
|
return(fp);
|
||||||
|
if ((fp = fopenp(fqname(configfile, CONFIGPREFIX, 0), "r")) != (FILE *)0)
|
||||||
|
return(fp);
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
/* constructed full path names don't need fqname() */
|
/* constructed full path names don't need fqname() */
|
||||||
|
|||||||
Reference in New Issue
Block a user