summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-30 15:06:25 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-30 15:06:25 +0000
commit3041f2156eae5dbcbe14562b6eef9389c9c50bdd (patch)
treeca28902bc25a94885e57d164c9db2de8b3d065d2 /iseq.c
parent0cc54369d76631b77cded2f5491cdaeb30d33ef0 (diff)
merge revision(s) r42230,r42231: [Backport #9651]
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)". * 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/branches/ruby_2_0_0@45473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/iseq.c b/iseq.c
index a52fd40d72..43e4c8273e 100644
--- a/iseq.c
+++ b/iseq.c
@@ -581,18 +581,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)
{
@@ -605,17 +593,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,