* io.c (argf_external_encoding, argf_internal_encoding): fix SEGV by

ARGF.external_encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2008-05-29 13:30:09 +00:00
parent 441be3ca06
commit 17248a467e
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,8 @@
Thu May 29 22:29:39 2008 Yusuke Endoh <mame@tsg.ne.jp>
* io.c (argf_external_encoding, argf_internal_encoding): fix SEGV by
ARGF.external_encoding.
Wed May 28 18:05:28 2008 Akinori MUSHA <knu@iDaemons.org>
* array.c (rb_ary_nitems, Init_Array): Axe Array#nitems().

10
io.c
View File

@ -6942,13 +6942,19 @@ rb_io_set_encoding(int argc, VALUE *argv, VALUE io)
static VALUE
argf_external_encoding(VALUE argf)
{
return rb_io_external_encoding(current_file);
if (!RTEST(current_file)) {
return rb_enc_from_encoding(rb_default_external_encoding());
}
return rb_io_external_encoding(rb_io_check_io(current_file));
}
static VALUE
argf_internal_encoding(VALUE argf)
{
return rb_io_internal_encoding(current_file);
if (!RTEST(current_file)) {
return rb_enc_from_encoding(rb_default_external_encoding());
}
return rb_io_internal_encoding(rb_io_check_io(current_file));
}
static VALUE