diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-27 06:58:28 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-27 06:58:28 +0000 |
commit | 0a20a506e1ee9e47ea89bb263c31adca013bcb95 (patch) | |
tree | ebd53ddc7d036bcaa2b155b72825f5612039cc8e /ruby.c | |
parent | 782f3bd3f9d89130e7b8486e82e2f7f270833013 (diff) | |
download | bundler-0a20a506e1ee9e47ea89bb263c31adca013bcb95.tar.gz |
* ruby.c (load_file): preserves $.. [ruby-dev:36937]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 35 |
1 files changed, 32 insertions, 3 deletions
@@ -1203,10 +1203,22 @@ process_options(VALUE arg) return iseq; } -static NODE * -load_file(VALUE parser, const char *fname, int script, struct cmdline_options *opt) +struct load_file_arg { + VALUE parser; + const char *fname; + int script; + struct cmdline_options *opt; +}; + +static VALUE +load_file_internal(VALUE arg) { extern VALUE rb_stdin; + struct load_file_arg *argp = (struct load_file_arg *)arg; + VALUE parser = argp->parser; + const char *fname = argp->fname; + int script = argp->script; + struct cmdline_options *opt = argp->opt; VALUE f; int line_start = 1; NODE *tree = 0; @@ -1353,7 +1365,24 @@ load_file(VALUE parser, const char *fname, int script, struct cmdline_options *o else if (f != rb_stdin) { rb_io_close(f); } - return tree; + return (VALUE)tree; +} + +static VALUE +restore_lineno(VALUE lineno) +{ + return rb_gv_set("$.", lineno); +} + +static NODE * +load_file(VALUE parser, const char *fname, int script, struct cmdline_options *opt) +{ + struct load_file_arg arg; + arg.parser = parser; + arg.fname = fname; + arg.script = script; + arg.opt = opt; + return (NODE *)rb_ensure(load_file_internal, (VALUE)&arg, restore_lineno, rb_gv_get("$.")); } void * |