ruby-changes:3764
From: ko1@a...
Date: Sat, 26 Jan 2008 19:31:22 +0900 (JST)
Subject: [ruby-changes:3764] akr - Ruby:r15253 (trunk): * marshal.c (w_object): dump string encoding in USERDEF.
akr 2008-01-26 19:31:11 +0900 (Sat, 26 Jan 2008)
New Revision: 15253
Modified files:
trunk/ChangeLog
trunk/marshal.c
trunk/test/ruby/test_marshal.rb
Log:
* marshal.c (w_object): dump string encoding in USERDEF.
[ruby-dev:33401]
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15253&r2=15252&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_marshal.rb?r1=15253&r2=15252&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/marshal.c?r1=15253&r2=15252&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15252)
+++ ChangeLog (revision 15253)
@@ -1,3 +1,8 @@
+Sat Jan 26 19:08:45 2008 Tanaka Akira <akr@f...>
+
+ * marshal.c (w_object): dump string encoding in USERDEF.
+ [ruby-dev:33401]
+
Sat Jan 26 17:42:23 2008 Koichi Sasada <ko1@a...>
* compile.c (iseq_compile_each): validate argument expr of "next"
Index: marshal.c
===================================================================
--- marshal.c (revision 15252)
+++ marshal.c (revision 15253)
@@ -613,7 +613,7 @@
w_class(TYPE_USERDEF, obj, arg, Qfalse);
w_bytes(RSTRING_PTR(v), RSTRING_LEN(v), arg);
if (hasiv2) {
- w_ivar(obj, ivtbl2, &c_arg);
+ w_ivar(v, ivtbl2, &c_arg);
}
else if (hasiv) {
w_ivar(obj, ivtbl, &c_arg);
Index: test/ruby/test_marshal.rb
===================================================================
--- test/ruby/test_marshal.rb (revision 15252)
+++ test/ruby/test_marshal.rb (revision 15253)
@@ -57,6 +57,7 @@
def initialize(str)
@str = str
end
+ attr_reader :str
def _dump(limit)
@str
end
@@ -73,4 +74,14 @@
}
assert_equal("marshal data too short", e.message)
end
+
+
+ def test_userdef_encoding
+ s1 = "\xa4\xa4".force_encoding("euc-jp")
+ o1 = C.new(s1)
+ m = Marshal.dump(o1)
+ o2 = Marshal.load(m)
+ s2 = o2.str
+ assert_equal(s1, s2)
+ end
end
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/