# HG changeset patch # User jwe # Date 1077900059 0 # Node ID 6202d9b75f830d7e1d9934b286622602c60db378 # Parent 62a606d4939370cbd4378d0416ea426468108dd2 [project @ 2004-02-27 16:40:59 by jwe] diff -r 62a606d49393 -r 6202d9b75f83 src/ChangeLog --- a/src/ChangeLog Wed Feb 25 05:48:50 2004 +0000 +++ b/src/ChangeLog Fri Feb 27 16:40:59 2004 +0000 @@ -1,3 +1,8 @@ +2004-02-27 John W. Eaton + + * octave.cc (execute_startup_files): Don't find current directory + for absolute name of local_rc until after executing home_rc. + 2004-02-24 John W. Eaton * input.cc (input_event_hook): Return type is now int. Return 0. diff -r 62a606d49393 -r 6202d9b75f83 src/octave.cc --- a/src/octave.cc Wed Feb 25 05:48:50 2004 +0000 +++ b/src/octave.cc Fri Feb 27 16:40:59 2004 +0000 @@ -235,7 +235,7 @@ // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set, .octaverc // is assumed. - int home_rc_already_executed = 0; + bool home_rc_already_executed = false; std::string initfile = octave_env::getenv ("OCTAVE_INITFILE"); @@ -244,9 +244,9 @@ std::string home_dir = octave_env::get_home_directory (); - std::string home_rc = home_dir + file_ops::dir_sep_str + initfile; - std::string local_rc - = octave_env::getcwd () + file_ops::dir_sep_str + initfile; + std::string home_rc = octave_env::make_absolute (initfile, home_dir); + + std::string local_rc; if (! home_dir.empty ()) { @@ -258,15 +258,31 @@ if (fs_home_rc) { + // We want to check for curr_dir after executing home_rc + // because doing that may change the working directory. + + std::string curr_dir = octave_env::getcwd (); + + local_rc = octave_env::make_absolute (initfile, curr_dir); + file_stat fs_dot_rc (local_rc); if (fs_dot_rc && fs_home_rc.ino () == fs_dot_rc.ino ()) - home_rc_already_executed = 1; + home_rc_already_executed = true; } } if (! home_rc_already_executed) - parse_and_execute (local_rc, verbose); + { + if (local_rc.empty ()) + { + std::string curr_dir = octave_env::getcwd (); + + local_rc = octave_env::make_absolute (initfile, curr_dir); + } + + parse_and_execute (local_rc, verbose); + } } unwind_protect::run_frame ("execute_startup_files");