diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | marshal.c | 2 | ||||
-rw-r--r-- | test/ruby/test_marshal.rb | 11 |
3 files changed, 17 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Sat Jan 26 19:08:45 2008 Tanaka Akira <akr@fsij.org> + + * marshal.c (w_object): dump string encoding in USERDEF. + [ruby-dev:33401] + Sat Jan 26 17:42:23 2008 Koichi Sasada <ko1@atdot.net> * compile.c (iseq_compile_each): validate argument expr of "next" @@ -613,7 +613,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) 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); diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index e2151e71c5..a7f28c0f8b 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -57,6 +57,7 @@ class TestMarshal < Test::Unit::TestCase def initialize(str) @str = str end + attr_reader :str def _dump(limit) @str end @@ -73,4 +74,14 @@ class TestMarshal < Test::Unit::TestCase } 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 |