diff options
author | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-26 21:19:57 +0000 |
---|---|---|
committer | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-26 21:19:57 +0000 |
commit | 7257a5d24fa857f8d295f04b43afd498905efb72 (patch) | |
tree | 43a6fbb9dd54816b1c1a284ffc7fba3adac67337 /libgfortran/runtime/main.c | |
parent | 645899f229abd036a1eaba6b7089a8767517146c (diff) | |
download | gcc-7257a5d24fa857f8d295f04b43afd498905efb72.tar.gz |
fortran/
2009-05-26 Tobias Burnus <burnus@net-b.de>
PR fortran/39178
* gfortranspec.c (lang_specific_driver): Stop linking
libgfortranbegin.
* trans-decl.c (gfc_build_builtin_function_decls): Stop
making MAIN__ publicly visible.
(gfc_build_builtin_function_decls): Add
gfor_fndecl_set_args.
(create_main_function) New function.
(gfc_generate_function_code): Use it.
libgfortran/
2009-05-26 Tobias Burnus <burnus@net-b.de>
PR fortran/39178
* runtime/main.c (store_exe_path): Make static
and multiple-times callable.
(set_args): Call store_exe_path.
* libgfortran.h: Remove store_exe_path prototype.
* fmain.c (main): Remove store_exe_path call.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147883 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/runtime/main.c')
-rw-r--r-- | libgfortran/runtime/main.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/libgfortran/runtime/main.c b/libgfortran/runtime/main.c index 3cccc3d0304..6df2775d26e 100644 --- a/libgfortran/runtime/main.c +++ b/libgfortran/runtime/main.c @@ -69,31 +69,12 @@ determine_endianness (void) static int argc_save; static char **argv_save; -/* Set the saved values of the command line arguments. */ - -void -set_args (int argc, char **argv) -{ - argc_save = argc; - argv_save = argv; -} - -/* Retrieve the saved values of the command line arguments. */ - -void -get_args (int *argc, char ***argv) -{ - *argc = argc_save; - *argv = argv_save; -} - - static const char *exe_path; static int please_free_exe_path_when_done; /* Save the path under which the program was called, for use in the backtrace routines. */ -void +static void store_exe_path (const char * argv0) { #ifndef PATH_MAX @@ -106,6 +87,10 @@ store_exe_path (const char * argv0) char buf[PATH_MAX], *cwd, *path; + /* This can only happen if store_exe_path is called multiple times. */ + if (please_free_exe_path_when_done) + free ((char *) exe_path); + /* On the simulator argv is not set. */ if (argv0 == NULL || argv0[0] == '/') { @@ -128,6 +113,7 @@ store_exe_path (const char * argv0) please_free_exe_path_when_done = 1; } + /* Return the full path of the executable. */ char * full_exe_path (void) @@ -135,6 +121,28 @@ full_exe_path (void) return (char *) exe_path; } + +/* Set the saved values of the command line arguments. */ + +void +set_args (int argc, char **argv) +{ + argc_save = argc; + argv_save = argv; + store_exe_path (argv[0]); +} + + +/* Retrieve the saved values of the command line arguments. */ + +void +get_args (int *argc, char ***argv) +{ + *argc = argc_save; + *argv = argv_save; +} + + /* Initialize the runtime library. */ static void __attribute__((constructor)) |