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

ruby-changes:3771

From: ko1@a...
Date: Sun, 27 Jan 2008 06:02:15 +0900 (JST)
Subject: [ruby-changes:3771] akr - Ruby:r15260 (trunk): * re.c (rb_reg_preprocess): force fixed encoding when ASCII

akr	2008-01-27 06:01:52 +0900 (Sun, 27 Jan 2008)

  New Revision: 15260

  Modified files:
    trunk/ChangeLog
    trunk/re.c
    trunk/test/ruby/test_utf16.rb

  Log:
    * re.c (rb_reg_preprocess): force fixed encoding when ASCII
      incompatible source string.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15260&r2=15259&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_utf16.rb?r1=15260&r2=15259&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/re.c?r1=15260&r2=15259&diff_format=u

Index: re.c
===================================================================
--- re.c	(revision 15259)
+++ re.c	(revision 15260)
@@ -1908,7 +1908,13 @@
 
     buf = rb_str_buf_new(0);
 
-    *fixed_enc = 0;
+    if (rb_enc_asciicompat(enc))
+        *fixed_enc = 0;
+    else {
+        *fixed_enc = enc;
+        rb_enc_associate(buf, enc);
+    }
+
     if (unescape_nonascii(p, end, enc, buf, fixed_enc, err) != 0)
         return Qnil;
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15259)
+++ ChangeLog	(revision 15260)
@@ -1,3 +1,8 @@
+Sun Jan 27 05:56:39 2008  Tanaka Akira  <akr@f...>
+
+	* re.c (rb_reg_preprocess): force fixed encoding when ASCII
+	  incompatible source string.
+
 Sat Jan 26 23:46:33 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* sprintf.c (rb_str_format): zero-precision zero should be empty.
Index: test/ruby/test_utf16.rb
===================================================================
--- test/ruby/test_utf16.rb	(revision 15259)
+++ test/ruby/test_utf16.rb	(revision 15260)
@@ -115,4 +115,10 @@
   def test_regexp_union
     enccall(Regexp, :union, "aa".force_encoding("utf-16be"), "bb".force_encoding("utf-16be"))
   end
+
+  def test_empty_regexp
+    s = "".force_encoding("utf-16be")
+    assert_equal(Encoding.find("utf-16be"), Regexp.new(s).encoding,
+                "Regexp.new(#{encdump s}).encoding")
+  end
 end

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

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