2012-01-11 Tobias Burnus <burnus@net-b.de>
PR fortran/51803
* runtime/main.c (store_exe_path): Handle a failure of
getcwd and take absolute pathnames into account.
===================================================================
@@ -116,12 +116,17 @@ store_exe_path (const char * argv0)
memset (buf, 0, sizeof (buf));
#ifdef HAVE_GETCWD
cwd = getcwd (buf, sizeof (buf));
- if (!cwd)
- cwd = ".";
#else
- cwd = ".";
+ cwd = NULL;
#endif
+ if (!cwd || argv0[0] == DIR_SEPARATOR)
+ {
+ exe_path = argv0;
+ please_free_exe_path_when_done = 0;
+ return;
+ }
+
/* exe_path will be cwd + "/" + argv[0] + "\0". This will not work
if the executable is not in the cwd, but at this point we're out
of better ideas. */