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

ruby-changes:3006

From: ko1@a...
Date: 23 Dec 2007 02:28:43 +0900
Subject: [ruby-changes:3006] matz - Ruby:r14498 (trunk): * io.c (rb_io_mode_enc): do not set encoding unless explicitly

matz	2007-12-23 02:28:20 +0900 (Sun, 23 Dec 2007)

  New Revision: 14498

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/version.h

  Log:
    * io.c (rb_io_mode_enc): do not set encoding unless explicitly
      specified.
    
    * io.c (rb_io_check_readable): fill fptr->enc by default_external
      if it's empty.
    
    * io.c (io_enc_str): fptr->enc is always set for reading IO (by
      rb_io_check_readable(fptr)).

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/version.h?r1=14498&r2=14497
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14498&r2=14497
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=14498&r2=14497

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14497)
+++ ChangeLog	(revision 14498)
@@ -1,3 +1,14 @@
+Sun Dec 23 01:56:18 2007  Yukihiro Matsumoto  <matz@r...>
+
+	* io.c (rb_io_mode_enc): do not set encoding unless explicitly
+	  specified.
+
+	* io.c (rb_io_check_readable): fill fptr->enc by default_external
+	  if it's empty.
+
+	* io.c (io_enc_str): fptr->enc is always set for reading IO (by
+	  rb_io_check_readable(fptr)).
+
 Sun Dec 23 01:18:06 2007  David Flanagan  <david@d...>
 
 	* io.c, io.h: temporary patch to partially implement
Index: io.c
===================================================================
--- io.c	(revision 14497)
+++ io.c	(revision 14498)
@@ -347,8 +347,10 @@
     if (fptr->wbuf_len) {
         io_fflush(fptr);
     }
-    if (!fptr->enc && fptr->fd == 0) {
-	fptr->enc = rb_default_external_encoding();
+    if (!fptr->enc) {
+	fptr->enc = (fptr->fd == 0)
+	    ? rb_default_external_encoding()
+	    : rb_ascii_encoding();
     }
 }
 
@@ -627,7 +629,7 @@
      * the strings encoding then we must transcode before writing.
      * We must also transcode if two encodings were specified
      */
-    if (fptr->enc && (fptr->enc2 || fptr->enc != rb_enc_get(str))) {
+    if (fptr->enc) {
 	/* transcode str before output */
 	/* the methods in transcode.c are static, so call indirectly */
 	/* Can't use encode! because puts writes a frozen newline */
@@ -1298,19 +1300,17 @@
 io_enc_str(VALUE str, rb_io_t *fptr)
 {
     OBJ_TAINT(str);
-    if (fptr->enc) {
-	if (fptr->enc2) {
-	    /* two encodings, so transcode from enc2 to enc */
-            /* the methods in transcode.c are static, so call indirectly */
-	    str = rb_funcall(str, id_encode, 2, 
-			     rb_enc_from_encoding(fptr->enc2),
-			     rb_enc_from_encoding(fptr->enc));
-	}
-	else {
-	    /* just one encoding, so associate it with the string */
-	    rb_enc_associate(str, fptr->enc);
-	}
+    if (fptr->enc2) {
+	/* two encodings, so transcode from enc2 to enc */
+	/* the methods in transcode.c are static, so call indirectly */
+	str = rb_funcall(str, id_encode, 2, 
+			 rb_enc_from_encoding(fptr->enc2),
+			 rb_enc_from_encoding(fptr->enc));
     }
+    else {
+	/* just one encoding, so associate it with the string */
+	rb_enc_associate(str, fptr->enc);
+    }
     return str;
 }
 
@@ -2175,7 +2175,7 @@
     GetOpenFile(io, fptr);
     rb_io_check_readable(fptr);
 
-    enc = fptr->enc ? fptr->enc : rb_default_external_encoding();
+    enc = fptr->enc;
     READ_CHECK(fptr);
     if (io_fillbuf(fptr) < 0) {
 	return Qnil;
@@ -2327,7 +2327,7 @@
     GetOpenFile(io, fptr);
     rb_io_check_readable(fptr);
     if (NIL_P(c)) return Qnil;
-    enc = fptr->enc ? fptr->enc : rb_default_external_encoding();
+    enc = fptr->enc;
     if (FIXNUM_P(c)) {
 	int cc = FIX2INT(c);
 	char buf[16];
@@ -3123,12 +3123,6 @@
 	    }
 	}
     }
-    else if (fptr->mode & FMODE_BINMODE) {
-	fptr->enc = rb_ascii_encoding();
-    }
-    else {
-	fptr->enc = rb_default_external_encoding();
-    }
 }
 
 struct sysopen_struct {
Index: version.h
===================================================================
--- version.h	(revision 14497)
+++ version.h	(revision 14498)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2007-12-22"
+#define RUBY_RELEASE_DATE "2007-12-23"
 #define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20071222
+#define RUBY_RELEASE_CODE 20071223
 #define RUBY_PATCHLEVEL 0
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
 #define RUBY_VERSION_TEENY 0
 #define RUBY_RELEASE_YEAR 2007
 #define RUBY_RELEASE_MONTH 12
-#define RUBY_RELEASE_DAY 22
+#define RUBY_RELEASE_DAY 23
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];

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

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