diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | io.c | 13 |
2 files changed, 11 insertions, 4 deletions
@@ -3,6 +3,8 @@ Thu Jan 10 10:15:03 2008 Yukihiro Matsumoto <matz@ruby-lang.org> * io.c (io_encoding_set): IO.pipe("euc-jp", nil) should work as IO.pipe("euc-jp", nil). [ruby-dev:33000] + * io.c (io_encoding_set): handle nil for v1. + Thu Jan 10 02:41:22 2008 Yukihiro Matsumoto <matz@ruby-lang.org> * io.c (rb_io_binmode): should not alter encoding. [ruby-dev:32918] @@ -5627,12 +5627,17 @@ io_encoding_set(rb_io_t *fptr, int argc, VALUE v1, VALUE v2) fptr->enc = rb_to_encoding(v2); } else if (argc == 1) { - VALUE tmp = rb_check_string_type(v1); - if (!NIL_P(tmp)) { - mode_enc(fptr, StringValueCStr(tmp)); + if if (NIL_P(v1)) { + fptr->enc = 0; } else { - fptr->enc = rb_to_encoding(v1); + VALUE tmp = rb_check_string_type(v1); + if (!NIL_P(tmp)) { + mode_enc(fptr, StringValueCStr(tmp)); + } + else { + fptr->enc = rb_to_encoding(v1); + } } } } |