summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-21 10:39:59 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-21 10:39:59 +0000
commitf4ef96e6a292b70947adbeca4e12fb7943718e8e (patch)
treee35281b8f7a90704b0e0263f6957d26bcd91cb7a /ruby.c
parenta598fcc8c1412f82453f709433275f52d29f0501 (diff)
* ruby.c (process_options): need to acquire env from TOPLEVEL_BINDING
each time. `bind->env' may update after `eval()'. [Bug #7536] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ruby.c b/ruby.c
index 7a0310c..0ec8219 100644
--- a/ruby.c
+++ b/ruby.c
@@ -559,10 +559,9 @@ require_libraries(VALUE *req_list)
}
static rb_env_t*
-toplevel_context(void)
+toplevel_context(VALUE toplevel_binding)
{
rb_env_t *env;
- VALUE toplevel_binding = rb_const_get(rb_cObject, rb_intern("TOPLEVEL_BINDING"));
rb_binding_t *bind;
GetBindingPtr(toplevel_binding, bind);
@@ -1308,7 +1307,7 @@ process_options(int argc, char **argv, struct cmdline_options *opt)
char fbuf[MAXPATHLEN];
int i = (int)proc_options(argc, argv, opt, 0);
rb_thread_t *th = GET_THREAD();
- rb_env_t *env = 0;
+ VALUE toplevel_binding = Qundef;
argc -= i;
argv += i;
@@ -1438,9 +1437,10 @@ process_options(int argc, char **argv, struct cmdline_options *opt)
ruby_set_argv(argc, argv);
process_sflag(&opt->sflag);
- env = toplevel_context();
+ toplevel_binding = rb_const_get(rb_cObject, rb_intern("TOPLEVEL_BINDING"));
#define PREPARE_PARSE_MAIN(expr) do { \
+ rb_env_t *env = toplevel_context(toplevel_binding); \
th->parse_in_eval--; \
th->base_block = &env->block; \
expr; \
@@ -1533,8 +1533,9 @@ process_options(int argc, char **argv, struct cmdline_options *opt)
PREPARE_PARSE_MAIN({
VALUE path = Qnil;
- if (!opt->e_script && strcmp(opt->script, "-"))
+ if (!opt->e_script && strcmp(opt->script, "-")) {
path = rb_realpath_internal(Qnil, opt->script_name, 1);
+ }
iseq = rb_iseq_new_main(tree, opt->script_name, path);
});