main.c, rewrite readinit

This commit is contained in:
rlar 2011-07-02 15:26:28 +00:00
parent 3c8a18a93b
commit c161ee2e62
1 changed files with 12 additions and 20 deletions

View File

@ -1076,28 +1076,20 @@ main(int argc, char **argv)
signal(SIGSYS, (SIGNAL_FUNCTION) sig_sys); signal(SIGSYS, (SIGNAL_FUNCTION) sig_sys);
#endif #endif
/* load user's initialisation file */
if (readinit) { if (readinit) {
bool good; /* load user's initialisation file
try accessing the initialisation file in the current directory
/* Try accessing the initialisation file in the current directory */ if that fails try the alternate name */
good = read_initialisation_file("",INITSTR); if(FALSE == read_initialisation_file("", INITSTR) &&
FALSE == read_initialisation_file("", ALT_INITSTR)) {
/* if that fail try the alternate name */ /* if that failed try in the user's home directory
if(good == FALSE) if their HOME environment variable is set */
good = read_initialisation_file("",ALT_INITSTR); char *homedir = getenv("HOME");
if(homedir != NULL)
/* if that failed try in the user's home directory if(FALSE == read_initialisation_file(homedir, INITSTR) &&
if their HOME environment variable is set */ FALSE == read_initialisation_file(homedir, ALT_INITSTR)) {
if(good == FALSE) { ;
char * homedir;
homedir = getenv("HOME");
if(homedir !=NULL) {
good = read_initialisation_file(homedir,INITSTR);
if(good == FALSE) {
good = read_initialisation_file(homedir,ALT_INITSTR);
} }
}
} }
} }