aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--io.c13
2 files changed, 11 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 2967c6c88c..dc9a359213 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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]
diff --git a/io.c b/io.c
index 2fc199d861..4b499bc6e6 100644
--- a/io.c
+++ b/io.c
@@ -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);
+ }
}
}
}