mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (rb_io_check_readable): side effect for STDIN removed.
(rb_io_external_encoding): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1b821cb4a3
commit
febc4b9923
3 changed files with 24 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Aug 19 00:34:24 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* io.c (rb_io_check_readable): side effect for STDIN removed.
|
||||
(rb_io_external_encoding): ditto.
|
||||
|
||||
Mon Aug 18 23:27:07 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* io.c (io_ungetbyte): renamed from io_ungetc.
|
||||
|
|
6
io.c
6
io.c
|
@ -388,9 +388,6 @@ rb_io_check_readable(rb_io_t *fptr)
|
|||
GetOpenFile(fptr->tied_io_for_writing, wfptr);
|
||||
io_fflush(wfptr);
|
||||
}
|
||||
if (!fptr->enc && fptr->fd == 0) {
|
||||
fptr->enc = rb_default_external_encoding();
|
||||
}
|
||||
}
|
||||
|
||||
static rb_encoding*
|
||||
|
@ -7359,9 +7356,6 @@ rb_io_external_encoding(VALUE io)
|
|||
if (fptr->enc2) {
|
||||
return rb_enc_from_encoding(fptr->enc2);
|
||||
}
|
||||
if (!fptr->enc && fptr->fd == 0) {
|
||||
fptr->enc = rb_default_external_encoding();
|
||||
}
|
||||
if (fptr->mode & FMODE_WRITABLE) {
|
||||
if (fptr->enc)
|
||||
return rb_enc_from_encoding(fptr->enc);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'test/unit'
|
||||
require 'tmpdir'
|
||||
require 'timeout'
|
||||
require_relative 'envutil'
|
||||
|
||||
class TestIO_M17N < Test::Unit::TestCase
|
||||
ENCS = [
|
||||
|
@ -662,5 +663,23 @@ EOT
|
|||
}
|
||||
end
|
||||
|
||||
def test_stdin_external_encoding_with_reopen
|
||||
with_tmpdir {
|
||||
open("tst", "w+") {|f|
|
||||
pid = spawn(EnvUtil.rubybin, '-e', <<-'End', 10=>f)
|
||||
io = IO.new(10, "r+")
|
||||
STDIN.reopen(io)
|
||||
STDIN.external_encoding
|
||||
STDIN.write "\u3042"
|
||||
STDIN.flush
|
||||
End
|
||||
Process.wait pid
|
||||
f.rewind
|
||||
result = f.read.force_encoding("ascii-8bit")
|
||||
assert_equal("\u3042".force_encoding("ascii-8bit"), result)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue