summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-21 05:47:12 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-21 05:47:12 +0000
commit7f2ca5ba7a5afd95354d7ea9a39741cebff38e70 (patch)
treeb724185f18f370755cb8264d89b205881cd8f4bb
parent3ce61d2a639a47d505fa9179d6d41f774c85ad92 (diff)
* io.c (argf_set_encoding): uses current_file after check for next
input. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--bootstraptest/test_io.rb4
-rw-r--r--bootstraptest/test_knownbug.rb4
-rw-r--r--io.c5
4 files changed, 13 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 3a3f858a34..ee043d61ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Feb 21 14:47:09 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (argf_set_encoding): uses current_file after check for next
+ input.
+
Thu Feb 21 11:10:49 2008 NARUSE, Yui <naruse@ruby-lang.org>
* string.c: replace rb_enc_copy by rb_enc_cr_str_copy or
diff --git a/bootstraptest/test_io.rb b/bootstraptest/test_io.rb
index 4974a1eeb9..07211050a6 100644
--- a/bootstraptest/test_io.rb
+++ b/bootstraptest/test_io.rb
@@ -69,3 +69,7 @@ assert_equal 'ok', %q{
File.unlink(tmpname)
:ok
}
+
+assert_normal_exit %q{
+ ARGF.set_encoding "foo"
+}
diff --git a/bootstraptest/test_knownbug.rb b/bootstraptest/test_knownbug.rb
index 7a697c76b8..c438231f2c 100644
--- a/bootstraptest/test_knownbug.rb
+++ b/bootstraptest/test_knownbug.rb
@@ -57,7 +57,3 @@ assert_normal_exit %q{
assert_normal_exit %q{
"".center(1, "\x80".force_encoding("utf-8"))
}, '[ruby-dev:33807]'
-
-assert_normal_exit %q{
- ARGF.set_encoding "foo"
-}
diff --git a/io.c b/io.c
index 1b98b6ae0d..c17fc9e93f 100644
--- a/io.c
+++ b/io.c
@@ -6103,8 +6103,11 @@ argf_set_encoding(int argc, VALUE *argv, VALUE io)
{
rb_io_t *fptr;
+ if (next_argv()) {
+ rb_raise(rb_eArgError, "no stream to set encoding");
+ }
rb_io_set_encoding(argc, argv, current_file);
- GetOpenFile(io, fptr);
+ GetOpenFile(current_file, fptr);
argf_enc = fptr->enc;
argf_enc2 = fptr->enc2;
return io;