| OLD | NEW |
| 1 /* Copyright (C) 2002-2003, 2005, 2007, 2009 Free Software Foundation, Inc. | 1 /* Copyright (C) 2002-2003, 2005, 2007, 2009 Free Software Foundation, Inc. |
| 2 Contributed by Andy Vaught and Paul Brook <paul@nowt.org> | 2 Contributed by Andy Vaught and Paul Brook <paul@nowt.org> |
| 3 | 3 |
| 4 This file is part of the GNU Fortran 95 runtime library (libgfortran). | 4 This file is part of the GNU Fortran 95 runtime library (libgfortran). |
| 5 | 5 |
| 6 Libgfortran is free software; you can redistribute it and/or modify | 6 Libgfortran is free software; you can redistribute it and/or modify |
| 7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
| 8 the Free Software Foundation; either version 3, or (at your option) | 8 the Free Software Foundation; either version 3, or (at your option) |
| 9 any later version. | 9 any later version. |
| 10 | 10 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 if (argv0 == NULL || argv0[0] == '/') | 110 if (argv0 == NULL || argv0[0] == '/') |
| 111 { | 111 { |
| 112 exe_path = argv0; | 112 exe_path = argv0; |
| 113 please_free_exe_path_when_done = 0; | 113 please_free_exe_path_when_done = 0; |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 | 116 |
| 117 memset (buf, 0, sizeof (buf)); | 117 memset (buf, 0, sizeof (buf)); |
| 118 #ifdef HAVE_GETCWD | 118 #ifdef HAVE_GETCWD |
| 119 cwd = getcwd (buf, sizeof (buf)); | 119 cwd = getcwd (buf, sizeof (buf)); |
| 120 if (cwd == NULL) |
| 121 { |
| 122 cwd = ""; |
| 123 } |
| 120 #else | 124 #else |
| 121 cwd = ""; | 125 cwd = ""; |
| 122 #endif | 126 #endif |
| 123 | 127 |
| 124 /* exe_path will be cwd + "/" + argv[0] + "\0" */ | 128 /* exe_path will be cwd + "/" + argv[0] + "\0" */ |
| 125 path = malloc (strlen (cwd) + 1 + strlen (argv0) + 1); | 129 path = malloc (strlen (cwd) + 1 + strlen (argv0) + 1); |
| 126 sprintf (path, "%s%c%s", cwd, DIR_SEPARATOR, argv0); | 130 sprintf (path, "%s%c%s", cwd, DIR_SEPARATOR, argv0); |
| 127 exe_path = path; | 131 exe_path = path; |
| 128 please_free_exe_path_when_done = 1; | 132 please_free_exe_path_when_done = 1; |
| 129 } | 133 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 /* Cleanup the runtime library. */ | 170 /* Cleanup the runtime library. */ |
| 167 | 171 |
| 168 static void __attribute__((destructor)) | 172 static void __attribute__((destructor)) |
| 169 cleanup (void) | 173 cleanup (void) |
| 170 { | 174 { |
| 171 close_units (); | 175 close_units (); |
| 172 | 176 |
| 173 if (please_free_exe_path_when_done) | 177 if (please_free_exe_path_when_done) |
| 174 free ((char *) exe_path); | 178 free ((char *) exe_path); |
| 175 } | 179 } |
| OLD | NEW |