From 93eed922b9a6e123fa8e6b28aa513365aab2f7df Mon Sep 17 00:00:00 2001 From: Kevin Tew Date: Wed, 9 Jun 2010 10:30:55 -0600 Subject: [PATCH] Move collects path initialization before kernel creation --- src/racket/cmdline.inc | 101 +++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 43 deletions(-) diff --git a/src/racket/cmdline.inc b/src/racket/cmdline.inc index 1bc3f94272..f823161c84 100644 --- a/src/racket/cmdline.inc +++ b/src/racket/cmdline.inc @@ -517,6 +517,24 @@ int osk_not_console = 0; # endif #endif +static Scheme_Object *create_cmdline_args_vector(int argc, char *args[]) +{ + int i; + Scheme_Object *v; + v = scheme_make_vector(argc, NULL); + for (i = 0; i < argc; i++) { + Scheme_Object *so; + so = scheme_make_locale_string(args[i]); + SCHEME_SET_CHAR_STRING_IMMUTABLE(so); + SCHEME_VEC_ELS(v)[i] = so; + } + if (argc) + SCHEME_SET_VECTOR_IMMUTABLE(v); + scheme_set_param(scheme_current_config(), MZCONFIG_CMDLINE_ARGS, v); + return v; +} + + static int run_from_cmd_line(int argc, char *_argv[], Scheme_Env *(*mk_basic_env)(void), int (*cont_run)(FinishArgs *f)) @@ -527,7 +545,6 @@ static int run_from_cmd_line(int argc, char *_argv[], Scheme_Object *sch_argv, *collects_path = NULL, *collects_extra = NULL, *addon_dir = NULL; - int i; #ifndef DONT_PARSE_COMMAND_LINE char **evals_and_loads, *real_switch = NULL, specific_switch[2]; int *eval_kind, num_enl; @@ -1101,24 +1118,53 @@ static int run_from_cmd_line(int argc, char *_argv[], #endif scheme_set_logging(syslog_level, stderr_level); + + { +#ifndef NO_FILE_SYSTEM_UTILS + /* Setup path for "collects" collection directory: */ + Scheme_Object *l, *r; - global_env = mk_basic_env(); + if (!collects_path) + collects_path = scheme_make_path(_coldir XFORM_OK_PLUS _coldir_offset); + else + collects_path = scheme_path_to_complete_path(collects_path, NULL); + scheme_set_collects_path(collects_path); - sch_argv = scheme_make_vector(argc, NULL); - for (i = 0; i < argc; i++) { - Scheme_Object *so; - so = scheme_make_locale_string(argv[i]); - SCHEME_SET_CHAR_STRING_IMMUTABLE(so); - SCHEME_VEC_ELS(sch_argv)[i] = so; + /* Make list of additional collection paths: */ + if (collects_extra) + r = reverse_path_list(collects_extra, 1); + else + r = scheme_make_null(); + + { + int len, offset; + l = scheme_make_null(); + offset = _coldir_offset; + while (1) { + len = strlen(_coldir XFORM_OK_PLUS offset); + offset += len + 1; + if (!_coldir[offset]) + break; + l = scheme_make_pair(scheme_make_path(_coldir XFORM_OK_PLUS offset), l); + } + l = reverse_path_list(l, 0); + } +#endif + + /* Creates the main kernel environment */ + global_env = mk_basic_env(); + + sch_argv = create_cmdline_args_vector(argc, argv); + +#ifndef NO_FILE_SYSTEM_UTILS + scheme_init_collection_paths_post(global_env, l, r); +#endif } - if (argc) - SCHEME_SET_VECTOR_IMMUTABLE(sch_argv); - scheme_set_param(scheme_current_config(), MZCONFIG_CMDLINE_ARGS, sch_argv); if (no_compiled) scheme_set_param(scheme_current_config(), MZCONFIG_USE_COMPILED_KIND, scheme_make_null()); - { + { Scheme_Object *ps; scheme_set_exec_cmd(prog); if (!sprog) @@ -1142,37 +1188,6 @@ static int run_from_cmd_line(int argc, char *_argv[], #endif if (addon_dir) scheme_set_addon_dir(addon_dir); } - /* Setup path for "collects" collection directory: */ - { - Scheme_Object *l, *r; - int len, offset; - - if (!collects_path) - collects_path = scheme_make_path(_coldir XFORM_OK_PLUS _coldir_offset); - else - collects_path = scheme_path_to_complete_path(collects_path, NULL); - scheme_set_collects_path(collects_path); - - /* Make list of additional collection paths: */ - if (collects_extra) - r = reverse_path_list(collects_extra, 1); - else - r = scheme_make_null(); - - l = scheme_make_null(); - offset = _coldir_offset; - while (1) { - len = strlen(_coldir XFORM_OK_PLUS offset); - offset += len + 1; - if (!_coldir[offset]) - break; - l = scheme_make_pair(scheme_make_path(_coldir XFORM_OK_PLUS offset), - l); - } - l = reverse_path_list(l, 0); - - scheme_init_collection_paths_post(global_env, l, r); - } #endif /* NO_FILE_SYSTEM_UTILS */ scheme_seal_parameters();