From 064b2f790c334fa6d2e7fa43fc389e229035e13a Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sun, 30 Oct 2016 00:52:04 +0200 Subject: [PATCH] main.c, add USERPROFILE to search path for .spiceinit search sequence: current directory, HOME, USERPROFILE --- src/main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index ca5501983..c1cbeaec4 100644 --- a/src/main.c +++ b/src/main.c @@ -1138,16 +1138,26 @@ main(int argc, char **argv) /* load user's initialisation file try accessing the initialisation file in the current directory if that fails try the alternate name */ - if (FALSE == read_initialisation_file("", INITSTR) && + if (FALSE == read_initialisation_file("", INITSTR) && FALSE == read_initialisation_file("", ALT_INITSTR)) { /* if that failed try in the user's home directory - if their HOME environment variable is set */ + if their HOME environment variable is set */ char *homedir = getenv("HOME"); - if (homedir) - if (FALSE == read_initialisation_file(homedir, INITSTR) && + if (homedir) { + if (FALSE == read_initialisation_file(homedir, INITSTR) && FALSE == read_initialisation_file(homedir, ALT_INITSTR)) { ; } + } + else { + /* If there is no HOME environment (e.g. MS Windows), try user's profile directory */ + homedir = getenv("USERPROFILE"); + if (homedir) + if (FALSE == read_initialisation_file(homedir, INITSTR) && + FALSE == read_initialisation_file(homedir, ALT_INITSTR)) { + ; + } + } } }