mirror of
https://github.com/ruby/ruby.git
synced 2025-08-16 05:59:00 +02:00
* include/ruby/io.h, io.c: reverted r21709.
* ruby.c (load_file_internal): nothing to read if EOF reached while reading shebang. [ruby-core:30910] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@28451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c69fda5e2a
commit
1f1937111d
5 changed files with 43 additions and 22 deletions
12
ruby.c
12
ruby.c
|
@ -1593,6 +1593,10 @@ load_file_internal(VALUE arg)
|
|||
else if (!NIL_P(c)) {
|
||||
rb_io_ungetbyte(f, c);
|
||||
}
|
||||
else {
|
||||
if (f != rb_stdin) rb_io_close(f);
|
||||
f = Qnil;
|
||||
}
|
||||
rb_vm_set_progname(rb_progname = opt->script_name);
|
||||
require_libraries(&opt->req_list); /* Why here? unnatural */
|
||||
}
|
||||
|
@ -1605,6 +1609,11 @@ load_file_internal(VALUE arg)
|
|||
else {
|
||||
enc = rb_usascii_encoding();
|
||||
}
|
||||
if (NIL_P(f)) {
|
||||
f = rb_str_new(0, 0);
|
||||
rb_enc_associate(f, enc);
|
||||
return (VALUE)rb_parser_compile_string(parser, fname, f, line_start);
|
||||
}
|
||||
rb_funcall(f, set_encoding, 2, rb_enc_from_encoding(enc), rb_str_new_cstr("-"));
|
||||
tree = rb_parser_compile_file(parser, fname, f, line_start);
|
||||
rb_funcall(f, set_encoding, 1, rb_parser_encoding(parser));
|
||||
|
@ -1614,9 +1623,6 @@ load_file_internal(VALUE arg)
|
|||
else if (f != rb_stdin) {
|
||||
rb_io_close(f);
|
||||
}
|
||||
else {
|
||||
rb_io_ungetbyte(f, Qnil);
|
||||
}
|
||||
return (VALUE)tree;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue