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

ruby-changes:47945

From: nobu <ko1@a...>
Date: Fri, 29 Sep 2017 17:15:56 +0900 (JST)
Subject: [ruby-changes:47945] nobu:r60060 (trunk): string.c: ASCII-incompatible is not ASCII only

nobu	2017-09-29 17:15:50 +0900 (Fri, 29 Sep 2017)

  New Revision: 60060

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60060

  Log:
    string.c: ASCII-incompatible is not ASCII only
    
    * string.c (tr_trans): ASCII-incompatible encoding strings cannot
      be ASCII-only even if valid.  [ruby-core:83056] [Bug #13950]

  Modified files:
    trunk/string.c
    trunk/test/ruby/test_string.rb
Index: test/ruby/test_string.rb
===================================================================
--- test/ruby/test_string.rb	(revision 60059)
+++ test/ruby/test_string.rb	(revision 60060)
@@ -2063,8 +2063,13 @@ CODE https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L2063
     assert_equal(false, "\u3041\u3042".tr("\u3041", "a").ascii_only?)
 
     bug6156 = '[ruby-core:43335]'
+    bug13950 = '[ruby-core:83056] [Bug #13950]'
     str, range, star = %w[b a-z *].map{|s|s.encode("utf-16le")}
-    assert_equal(star, str.tr(range, star), bug6156)
+    result = str.tr(range, star)
+    assert_equal(star, result, bug6156)
+    assert_not_predicate(str, :ascii_only?)
+    assert_not_predicate(star, :ascii_only?)
+    assert_not_predicate(result, :ascii_only?, bug13950)
   end
 
   def test_tr!
Index: string.c
===================================================================
--- string.c	(revision 60059)
+++ string.c	(revision 60060)
@@ -6637,7 +6637,7 @@ tr_trans(VALUE str, VALUE src, VALUE rep https://github.com/ruby/ruby/blob/trunk/string.c#L6637
 	}
     }
 
-    if (cr == ENC_CODERANGE_VALID)
+    if (cr == ENC_CODERANGE_VALID && rb_enc_asciicompat(e1))
 	cr = ENC_CODERANGE_7BIT;
     str_modify_keep_cr(str);
     s = RSTRING_PTR(str); send = RSTRING_END(str);

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

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