[前][次][番号順一覧][スレッド一覧]

ruby-changes:7303

From: akr <ko1@a...>
Date: Sun, 24 Aug 2008 19:40:52 +0900 (JST)
Subject: [ruby-changes:7303] Ruby:r18822 (trunk): * io.c (rb_io_init_copy): copy encs.

akr	2008-08-24 19:40:37 +0900 (Sun, 24 Aug 2008)

  New Revision: 18822

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18822

  Log:
    * io.c (rb_io_init_copy): copy encs.

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/test/ruby/test_io_m17n.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18821)
+++ ChangeLog	(revision 18822)
@@ -1,3 +1,7 @@
+Sun Aug 24 19:40:13 2008  Tanaka Akira  <akr@f...>
+
+	* io.c (rb_io_init_copy): copy encs.
+
 Sun Aug 24 19:17:31 2008  Tanaka Akira  <akr@f...>
 
 	* io.c (rb_io_open): add an argument: vperm.
Index: io.c
===================================================================
--- io.c	(revision 18821)
+++ io.c	(revision 18822)
@@ -5075,6 +5075,7 @@
 
     /* 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;
Index: test/ruby/test_io_m17n.rb
===================================================================
--- test/ruby/test_io_m17n.rb	(revision 18821)
+++ test/ruby/test_io_m17n.rb	(revision 18822)
@@ -19,8 +19,8 @@
     }
   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 @@
     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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]