diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-27 14:31:19 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-27 14:31:19 +0000 |
commit | a67f1a9534322914367d6eb17eb01badd87e7f79 (patch) | |
tree | 23bef858db62ea6eba371eb345716415bf3ffb3c /ruby.c | |
parent | d9edd4ca87bff687dc9548de6517792443746ddd (diff) | |
download | ruby-a67f1a9534322914367d6eb17eb01badd87e7f79.tar.gz |
* 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/trunk@28451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -1598,6 +1598,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 */ } @@ -1610,6 +1614,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)); @@ -1619,9 +1628,6 @@ load_file_internal(VALUE arg) else if (f != rb_stdin) { rb_io_close(f); } - else { - rb_io_ungetbyte(f, Qnil); - } return (VALUE)tree; } |