comparison src/octave.cc @ 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 998cbb0a9e51
children d80376609fd1
comparison
equal deleted inserted replaced
84:ab04b34037f0 85:3abd838cc4b3
26 #ifdef __GNUG__ 26 #ifdef __GNUG__
27 #pragma implementation 27 #pragma implementation
28 #endif 28 #endif
29 29
30 #include <sys/types.h> 30 #include <sys/types.h>
31 #include <sys/stat.h>
31 #include <time.h> 32 #include <time.h>
32 #include <pwd.h> 33 #include <pwd.h>
33 #include <setjmp.h> 34 #include <setjmp.h>
34 #include <stdlib.h> 35 #include <stdlib.h>
35 #include <string.h> 36 #include <string.h>
228 229
229 parse_and_execute (sd, 0); 230 parse_and_execute (sd, 0);
230 231
231 // Try to execute commands from $HOME/.octaverc and ./.octaverc. 232 // Try to execute commands from $HOME/.octaverc and ./.octaverc.
232 233
234 char *home_rc = (char *) NULL;
233 if (home_directory != NULL) 235 if (home_directory != NULL)
234 { 236 {
235 char *rc = strconcat (home_directory, "/.octaverc"); 237 home_rc = strconcat (home_directory, "/.octaverc");
236 238 parse_and_execute (home_rc, 0);
237 parse_and_execute (rc, 0); 239 }
238 240
239 delete [] rc; 241 // Names alone are not enough.
240 } 242
241 243 struct stat home_rc_statbuf;
242 if (strcmp (the_current_working_directory, home_directory) != 0) 244 stat (home_rc, &home_rc_statbuf);
245 delete [] home_rc;
246
247 struct stat dot_rc_statbuf;
248 stat ("./.octaverc", &dot_rc_statbuf);
249
250 if (home_rc_statbuf.st_ino != dot_rc_statbuf.st_ino)
243 parse_and_execute ("./.octaverc", 0); 251 parse_and_execute ("./.octaverc", 0);
244 } 252 }
245 253
246 /* 254 /*
247 * Usage message with extra help. 255 * Usage message with extra help.