mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (rb_io_init_copy): copy encs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
98e34b223b
commit
329729da55
3 changed files with 34 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
|||
Sun Aug 24 19:40:13 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* io.c (rb_io_init_copy): copy encs.
|
||||
|
||||
Sun Aug 24 19:17:31 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* io.c (rb_io_open): add an argument: vperm.
|
||||
|
|
1
io.c
1
io.c
|
@ -5075,6 +5075,7 @@ rb_io_init_copy(VALUE dest, VALUE io)
|
|||
|
||||
/* copy rb_io_t structure */
|
||||
fptr->mode = orig->mode & ~FMODE_PREP;
|
||||
fptr->encs = orig->encs;
|
||||
fptr->pid = orig->pid;
|
||||
fptr->lineno = orig->lineno;
|
||||
if (!NIL_P(orig->pathv)) fptr->pathv = orig->pathv;
|
||||
|
|
|
@ -19,8 +19,8 @@ class TestIO_M17N < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
def with_pipe(enc=nil)
|
||||
r, w = IO.pipe(enc)
|
||||
def with_pipe(*args)
|
||||
r, w = IO.pipe(*args)
|
||||
begin
|
||||
yield r, w
|
||||
ensure
|
||||
|
@ -239,6 +239,33 @@ EOT
|
|||
w.close if w && !w.closed?
|
||||
end
|
||||
|
||||
def test_dup
|
||||
with_pipe("utf-8:euc-jp") {|r, w|
|
||||
w << "\u3042"
|
||||
w.close
|
||||
r2 = r.dup
|
||||
begin
|
||||
assert_equal("\xA4\xA2".force_encoding("euc-jp"), r2.read)
|
||||
ensure
|
||||
r2.close
|
||||
end
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
def test_dup_undef
|
||||
with_pipe("utf-8:euc-jp", :undef=>:replace) {|r, w|
|
||||
w << "\uFFFD"
|
||||
w.close
|
||||
r2 = r.dup
|
||||
begin
|
||||
assert_equal("?", r2.read)
|
||||
ensure
|
||||
r2.close
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def test_stdin
|
||||
assert_equal(Encoding.default_external, STDIN.external_encoding)
|
||||
assert_equal(nil, STDIN.internal_encoding)
|
||||
|
|
Loading…
Reference in a new issue