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

ruby-changes:13241

From: nobu <ko1@a...>
Date: Fri, 18 Sep 2009 23:51:33 +0900 (JST)
Subject: [ruby-changes:13241] Ruby:r25001 (trunk): * marshal.c (r_object0): entry regexp object before its encoding

nobu	2009-09-18 23:51:18 +0900 (Fri, 18 Sep 2009)

  New Revision: 25001

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

  Log:
    * marshal.c (r_object0): entry regexp object before its encoding
      name.  [ruby-core:25625]

  Modified files:
    trunk/ChangeLog
    trunk/marshal.c
    trunk/test/ruby/test_marshal.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25000)
+++ ChangeLog	(revision 25001)
@@ -1,3 +1,8 @@
+Fri Sep 18 23:51:17 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* marshal.c (r_object0): entry regexp object before its encoding
+	  name.  [ruby-core:25625]
+
 Fri Sep 18 16:29:16 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* common.mk (eval.o): needs vm.h.
Index: marshal.c
===================================================================
--- marshal.c	(revision 25000)
+++ marshal.c	(revision 25001)
@@ -1444,7 +1444,10 @@
 	{
 	    volatile VALUE str = r_bytes(arg);
 	    int options = r_byte(arg);
-	    v = rb_reg_new("", 0, options);
+	    VALUE args[2];
+	    args[0] = str;
+	    args[1] = INT2FIX(options);
+	    v = r_entry(rb_obj_alloc(rb_cRegexp), arg);
 	    if (ivp) {
 		r_ivar(v, arg);
 		*ivp = FALSE;
@@ -1455,9 +1458,8 @@
 #define f_gsub_bang(x,y,z) rb_funcall(x, rb_intern("gsub!"), 2, y, z)
 		f_gsub_bang(str, rb_reg_new("\\\\u", 3, 0), rb_usascii_str_new_cstr("u"));
 	    }
-	    str = r_entry(rb_reg_new_str(str, options), arg);
-	    rb_copy_generic_ivar(str, v);
-	    v = r_leave(str, arg);
+	    rb_obj_call_init(v, 2, args);
+	    v = r_leave(v, arg);
 	}
 	break;
 
Index: test/ruby/test_marshal.rb
===================================================================
--- test/ruby/test_marshal.rb	(revision 25000)
+++ test/ruby/test_marshal.rb	(revision 25001)
@@ -204,4 +204,12 @@
     a = ClassUTF8.new
     assert_instance_of(ClassUTF8, Marshal.load(Marshal.dump(a)), '[ruby-core:24790]')
   end
+
+  def test_regexp
+    bug2109 = '[ruby-core:25625]'
+    a = "\x82\xa0".force_encoding(Encoding::Windows_31J)
+    b = "\x82\xa2".force_encoding(Encoding::Windows_31J)
+    c = [/#{a}/, /#{b}/]
+    assert_equal(c, Marshal.load(Marshal.dump(c)))
+  end
 end

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

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