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

ruby-changes:29592

From: usa <ko1@a...>
Date: Wed, 26 Jun 2013 16:14:02 +0900 (JST)
Subject: [ruby-changes:29592] usa:r41644 (ruby_1_9_3): merge revision(s) 41250: [Backport #8516]

usa	2013-06-26 16:13:45 +0900 (Wed, 26 Jun 2013)

  New Revision: 41644

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

  Log:
    merge revision(s) 41250: [Backport #8516]
    
    * io.c (io_getc): fix 7bit coderange condition, check if ascii read
      data instead of read length. [ruby-core:55444] [Bug #8516]

  Modified directories:
    branches/ruby_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/io.c
    branches/ruby_1_9_3/test/ruby/test_io_m17n.rb
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 41643)
+++ ruby_1_9_3/ChangeLog	(revision 41644)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Wed Jun 26 16:13:25 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* io.c (io_getc): fix 7bit coderange condition, check if ascii read
+	  data instead of read length. [ruby-core:55444] [Bug #8516]
+
 Wed Jun 26 16:10:01 2013  Eric Hodel  <drbrain@s...>
 
 	* ext/socket/extconf.rb:  Enable RFC 3542 IPV6 socket options for OS X
Index: ruby_1_9_3/io.c
===================================================================
--- ruby_1_9_3/io.c	(revision 41643)
+++ ruby_1_9_3/io.c	(revision 41644)
@@ -3151,7 +3151,11 @@ io_getc(rb_io_t *fptr, rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/io.c#L3151
 	}
 	else {
 	    io_shift_cbuf(fptr, MBCLEN_CHARFOUND_LEN(r), &str);
-	    cr = ISASCII(r) ? ENC_CODERANGE_7BIT : ENC_CODERANGE_VALID;
+	    cr = ENC_CODERANGE_VALID;
+	    if (MBCLEN_CHARFOUND_LEN(r) == 1 && rb_enc_asciicompat(read_enc) &&
+		ISASCII(RSTRING_PTR(str)[0])) {
+		cr = ENC_CODERANGE_7BIT;
+	    }
 	}
 	str = io_enc_str(str, fptr);
 	ENC_CODERANGE_SET(str, cr);
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 41643)
+++ ruby_1_9_3/version.h	(revision 41644)
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 436
+#define RUBY_PATCHLEVEL 437
 
 #define RUBY_RELEASE_DATE "2013-06-26"
 #define RUBY_RELEASE_YEAR 2013
Index: ruby_1_9_3/test/ruby/test_io_m17n.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_io_m17n.rb	(revision 41643)
+++ ruby_1_9_3/test/ruby/test_io_m17n.rb	(revision 41644)
@@ -2067,7 +2067,17 @@ EOT https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_io_m17n.rb#L2067
       open("a", "wb") {|f| f.puts "a"}
       open("a", "rt") {|f| f.getc}
     }
-    assert(c.ascii_only?, "should be ascii_only #{bug4557}")
+    assert_predicate(c, :ascii_only?, bug4557)
+  end
+
+  def test_getc_conversion
+    bug8516 = '[ruby-core:55444] [Bug #8516]'
+    c = with_tmpdir {
+      open("a", "wb") {|f| f.putc "\xe1"}
+      open("a", "r:iso-8859-1:utf-8") {|f| f.getc}
+    }
+    assert_not_predicate(c, :ascii_only?, bug8516)
+    assert_equal(1, c.size, bug8516)
   end
 
   def test_default_mode_on_dosish

Property changes on: ruby_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r41250


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

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