summaryrefslogtreecommitdiffstats
path: root/libgfortran
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-11 14:39:28 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-11 14:39:28 +0000
commit3d4046597138fd2cd97cc916af404c30f85f69b8 (patch)
treef1d8fe218cd54aa92750dbada0cd3015f9ffb20e /libgfortran
parent301901d261378510a2cfbca3308b4973ef31391f (diff)
downloadppe42-gcc-3d4046597138fd2cd97cc916af404c30f85f69b8.tar.gz
ppe42-gcc-3d4046597138fd2cd97cc916af404c30f85f69b8.zip
2012-01-11 Tobias Burnus <burnus@net-b.de>
* runtime/main.c (store_exe_path): Fix absolute path detection for Windows. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183094 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog7
-rw-r--r--libgfortran/runtime/main.c16
2 files changed, 18 insertions, 5 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 3e27ed952c0..b1e2b049b4f 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,5 +1,10 @@
+2012-01-11 Tobias Burnus <burnus@net-b.de>
+
+ * runtime/main.c (store_exe_path): Fix absolute path
+ detection for Windows.
+
2012-01-11 Janne Blomqvist <jb@gcc.gnu.org>
- Mike Stump <mikestump@comcast.net>
+ Mike Stump <mikestump@comcast.net>
PR libfortran/51803
* runtime/main.c (store_exe_path): Handle getcwd failure and lack
of the function better.
diff --git a/libgfortran/runtime/main.c b/libgfortran/runtime/main.c
index 1cad5eff725..9ee47022cc9 100644
--- a/libgfortran/runtime/main.c
+++ b/libgfortran/runtime/main.c
@@ -86,7 +86,8 @@ store_exe_path (const char * argv0)
#define DIR_SEPARATOR '/'
#endif
- char buf[PATH_MAX], *cwd, *path;
+ char buf[PATH_MAX], *path;
+ const char *cwd;
/* This can only happen if store_exe_path is called multiple times. */
if (please_free_exe_path_when_done)
@@ -105,15 +106,22 @@ store_exe_path (const char * argv0)
}
#endif
- /* On the simulator argv is not set. */
- if (argv0 == NULL || argv0[0] == '/')
+ /* If the path is absolute or on a simulator where argv is not set. */
+#ifdef __MINGW32__
+ if (argv0 == NULL
+ || ('A' <= argv0[0] && argv0[0] <= 'Z' && argv0[1] == ':')
+ || ('a' <= argv0[0] && argv0[0] <= 'z' && argv0[1] == ':')
+ || (argv0[0] == '/' && argv0[1] == '/')
+ || (argv0[0] == '\\' && argv0[1] == '\\'))
+#else
+ if (argv0 == NULL || argv0[0] == DIR_SEPARATOR)
+#endif
{
exe_path = argv0;
please_free_exe_path_when_done = 0;
return;
}
- memset (buf, 0, sizeof (buf));
#ifdef HAVE_GETCWD
cwd = getcwd (buf, sizeof (buf));
if (!cwd)
OpenPOWER on IntegriCloud