diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-29 08:00:34 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-29 08:00:34 +0000 |
commit | aa2a845168537c1e495823bfe643924f7f19c28b (patch) | |
tree | 6f49444c0cb1ac4ca6ba8306d553a2f21741a079 /iseq.c | |
parent | 1f7839f12cd8dd253e9cc23381128ebbdab053f6 (diff) | |
download | ruby-aa2a845168537c1e495823bfe643924f7f19c28b.tar.gz |
parse.y, vm_eval.c: file encoding in eval
* parse.y (yycompile): store file name as String to keep the encoding.
* parse.y (rb_parser_compile_string_path, rb_parser_compile_file_path):
new functions to pass file name as a String.
* parse.y (gettable_gen): return a copy of the original file name, not
a copy in filesystem encoding.
* vm_eval.c (eval_string_with_cref): use Qundef instead of "(eval)".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r-- | iseq.c | 28 |
1 files changed, 12 insertions, 16 deletions
@@ -574,18 +574,6 @@ rb_iseq_load(VALUE data, VALUE parent, VALUE opt) return iseq_load(rb_cISeq, data, parent, opt); } -static NODE * -parse_string(VALUE str, const char *file, int line) -{ - VALUE parser = rb_parser_new(); - NODE *node = rb_parser_compile_string(parser, file, str, line); - - if (!node) { - rb_exc_raise(GET_THREAD()->errinfo); /* TODO: check err */ - } - return node; -} - VALUE rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE absolute_path, VALUE line, rb_block_t *base_block, VALUE opt) { @@ -598,17 +586,25 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE absolute_path, VALUE li TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == 0) { + VALUE parser; int ln = NUM2INT(line); - const char *fn = StringValueCStr(file); NODE *node; rb_compile_option_t option; + StringValueCStr(file); make_compile_option(&option, opt); + parser = rb_parser_new(); + if (RB_TYPE_P((src), T_FILE)) - node = rb_compile_file(fn, src, ln); - else - node = parse_string(StringValue(src), fn, ln); + node = rb_parser_compile_file_path(parser, file, src, ln); + else { + node = rb_parser_compile_string_path(parser, file, src, ln); + + if (!node) { + rb_exc_raise(GET_THREAD()->errinfo); /* TODO: check err */ + } + } if (base_block && base_block->iseq) { iseqval = rb_iseq_new_with_opt(node, base_block->iseq->location.label, |