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

ruby-changes:3179

From: ko1@a...
Date: 25 Dec 2007 15:45:15 +0900
Subject: [ruby-changes:3179] matz - Ruby:r14672 (trunk): * io.c (rb_io_external_encoding): should return nil for

matz	2007-12-25 15:44:58 +0900 (Tue, 25 Dec 2007)

  New Revision: 14672

  Modified files:
    trunk/ChangeLog
    trunk/io.c

  Log:
    * io.c (rb_io_external_encoding): should return nil for
      pass-through write IO.  [ruby-dev:32740]

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14672&r2=14671
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=14672&r2=14671

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14671)
+++ ChangeLog	(revision 14672)
@@ -1,3 +1,8 @@
+Tue Dec 25 15:42:49 2007  Yukihiro Matsumoto  <matz@r...>
+
+	* io.c (rb_io_external_encoding): should return nil for
+	  pass-through write IO.  [ruby-dev:32740]
+
 Tue Dec 25 15:24:57 2007  Tanaka Akira  <akr@f...>
 
 	* io.c (appendline): initialize rslen to 1 if rsptr is 0.
Index: io.c
===================================================================
--- io.c	(revision 14671)
+++ io.c	(revision 14672)
@@ -5921,6 +5921,7 @@
  *     io.external_encoding   => encoding
  *
  *  Returns the Encoding object that represents the encoding of the file.
+ *  If io is write mode and no encoding is specified, returns <code>nil</code>.
  */
 
 static VALUE
@@ -5935,6 +5936,11 @@
     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);
+	return Qnil;
+    }
     return rb_enc_from_encoding(io_read_encoding(fptr));
 }
 

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

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