Mercurial > hg > octave-lojdl
changeset 85:3abd838cc4b3
[project @ 1993-09-06 04:39:26 by jwe]
(execute_startup_files): Try harder to avoid executing $HOME/.octaverc
twice.
author | jwe |
---|---|
date | Mon, 06 Sep 1993 04:39:26 +0000 |
parents | ab04b34037f0 |
children | 723cc7235104 |
files | src/octave.cc |
diffstat | 1 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/octave.cc +++ b/src/octave.cc @@ -28,6 +28,7 @@ #endif #include <sys/types.h> +#include <sys/stat.h> #include <time.h> #include <pwd.h> #include <setjmp.h> @@ -230,16 +231,23 @@ // Try to execute commands from $HOME/.octaverc and ./.octaverc. + char *home_rc = (char *) NULL; if (home_directory != NULL) { - char *rc = strconcat (home_directory, "/.octaverc"); - - parse_and_execute (rc, 0); - - delete [] rc; + home_rc = strconcat (home_directory, "/.octaverc"); + parse_and_execute (home_rc, 0); } - if (strcmp (the_current_working_directory, home_directory) != 0) +// Names alone are not enough. + + struct stat home_rc_statbuf; + stat (home_rc, &home_rc_statbuf); + delete [] home_rc; + + struct stat dot_rc_statbuf; + stat ("./.octaverc", &dot_rc_statbuf); + + if (home_rc_statbuf.st_ino != dot_rc_statbuf.st_ino) parse_and_execute ("./.octaverc", 0); }