1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* marshal.c (r_ivar): should not set internal encoding ivar as an

ordinary ivar.  [ruby-dev:38596]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-06-13 00:58:30 +00:00
parent 4150c2c05d
commit d70719b061
3 changed files with 16 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Sat Jun 13 09:58:26 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (r_ivar): should not set internal encoding ivar as an
ordinary ivar. [ruby-dev:38596]
Sat Jun 13 07:08:40 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> Sat Jun 13 07:08:40 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_eval.c (rb_f_local_variables): now returns symbols. a patch from * vm_eval.c (rb_f_local_variables): now returns symbols. a patch from

View file

@ -1159,14 +1159,14 @@ r_ivar(VALUE obj, struct load_arg *arg)
len = r_long(arg); len = r_long(arg);
if (len > 0) { if (len > 0) {
while (len--) { do {
ID id = r_symbol(arg); ID id = r_symbol(arg);
VALUE val = r_object(arg); VALUE val = r_object(arg);
if (id == rb_id_encoding()) { if (id == rb_id_encoding()) {
int idx = rb_enc_find_index(StringValueCStr(val)); int idx = rb_enc_find_index(StringValueCStr(val));
if (idx > 0) rb_enc_associate_index(obj, idx); if (idx > 0) rb_enc_associate_index(obj, idx);
} }
if (id == rb_intern("E")) { else if (id == rb_intern("E")) {
if (val == Qfalse) rb_enc_associate_index(obj, rb_usascii_encindex()); if (val == Qfalse) rb_enc_associate_index(obj, rb_usascii_encindex());
else if (val == Qtrue) rb_enc_associate_index(obj, rb_utf8_encindex()); else if (val == Qtrue) rb_enc_associate_index(obj, rb_utf8_encindex());
/* bogus ignore */ /* bogus ignore */
@ -1174,7 +1174,7 @@ r_ivar(VALUE obj, struct load_arg *arg)
else { else {
rb_ivar_set(obj, id, val); rb_ivar_set(obj, id, val);
} }
} } while (--len > 0);
} }
} }

View file

@ -60,4 +60,12 @@ class TestEncoding < Test::Unit::TestCase
assert_instance_of(String, v) assert_instance_of(String, v)
end end
end end
def test_marshal
str = "".force_encoding("EUC-JP")
str2 = Marshal.load(Marshal.dump(str))
assert_equal(str, str2)
str2 = Marshal.load(Marshal.dump(str2))
assert_equal(str, str2, '[ruby-dev:38596]')
end
end end