sharedspice: make reading .spiceinit as robust as in
the standard executable.
This commit is contained in:
parent
1234c3bdf8
commit
89f0fb6d74
|
|
@ -579,9 +579,9 @@ name is the initialisation file's name
|
||||||
Return true on success
|
Return true on success
|
||||||
SJB 25th April 2005 */
|
SJB 25th April 2005 */
|
||||||
static bool
|
static bool
|
||||||
read_initialisation_file(char *dir, char *name)
|
read_initialisation_file(const char *dir, const char *name)
|
||||||
{
|
{
|
||||||
char *path;
|
const char *path;
|
||||||
bool result = FALSE;
|
bool result = FALSE;
|
||||||
|
|
||||||
/* check name */
|
/* check name */
|
||||||
|
|
@ -783,36 +783,43 @@ ngSpice_Init(SendChar* printfcn, SendStat* statusfcn, ControlledExit* ngspiceexi
|
||||||
tfree(s);
|
tfree(s);
|
||||||
}
|
}
|
||||||
#else /* ~ HAVE_PWD_H */
|
#else /* ~ HAVE_PWD_H */
|
||||||
/* load user's initialisation file .spiceinit (or old spice.rc)
|
/* load user's initialisation file
|
||||||
try accessing the initialisation file in the current directory,
|
try accessing the initialisation file .spiceinit in the current directory
|
||||||
or the user's home directories HOME (Linux) and USERPROFILE (MS Windows)*/
|
if that fails try the alternate name spice.rc, then look into the HOME
|
||||||
char *homedir;
|
directory, then into USERPROFILE */
|
||||||
bool userfileok = read_initialisation_file("", INITSTR); /*.spiceinit*/
|
do {
|
||||||
if (!userfileok) {
|
if (read_initialisation_file("", INITSTR) != FALSE) {
|
||||||
homedir = getenv("HOME");
|
break;
|
||||||
if (homedir)
|
|
||||||
userfileok = read_initialisation_file(homedir, INITSTR);
|
|
||||||
else {
|
|
||||||
homedir = getenv("USERPROFILE");
|
|
||||||
if (homedir)
|
|
||||||
userfileok = read_initialisation_file(homedir, INITSTR);
|
|
||||||
}
|
}
|
||||||
|
if (read_initialisation_file("", ALT_INITSTR) != FALSE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const char* const home = getenv("HOME");
|
||||||
|
if (home) {
|
||||||
|
if (read_initialisation_file(home, INITSTR) != FALSE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (read_initialisation_file(home, ALT_INITSTR) != FALSE) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!userfileok)
|
|
||||||
userfileok = read_initialisation_file("", ALT_INITSTR); /*spice.rc*/
|
|
||||||
if (!userfileok) {
|
|
||||||
homedir = getenv("HOME");
|
|
||||||
if (homedir)
|
|
||||||
userfileok = read_initialisation_file(homedir, ALT_INITSTR);
|
|
||||||
else {
|
|
||||||
homedir = getenv("USERPROFILE");
|
|
||||||
if (homedir)
|
|
||||||
userfileok = read_initialisation_file(homedir, ALT_INITSTR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!userfileok && ft_ngdebug)
|
{
|
||||||
fprintf(stdout, "Warning: No user initialization file .spiceinit or spice.rc found\n");
|
const char* const usr = getenv("USERPROFILE");
|
||||||
|
if (usr) {
|
||||||
|
if (read_initialisation_file(usr, INITSTR) != FALSE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (read_initialisation_file(usr, ALT_INITSTR) != FALSE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (0); /* end of case that init file is read */
|
||||||
|
|
||||||
#endif /* ~ HAVE_PWD_H */
|
#endif /* ~ HAVE_PWD_H */
|
||||||
|
|
||||||
if (!cp_getvar("nosighandling", CP_BOOL, NULL, 0))
|
if (!cp_getvar("nosighandling", CP_BOOL, NULL, 0))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue