diff --git a/ChangeLog b/ChangeLog index 80f9d4247b..0255a35925 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jul 1 08:40:26 2010 Nobuyoshi Nakada + + * marshal.c (w_object): suppress empty instance variable entry on + compatible dump objects. + Wed Jun 30 07:29:11 2010 Nobuyoshi Nakada * test/ruby/test_rubyoptions.rb (test_script_from_stdin): by using diff --git a/marshal.c b/marshal.c index 24807fd529..bf76e6d524 100644 --- a/marshal.c +++ b/marshal.c @@ -607,9 +607,6 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) return; } - if ((hasiv = has_ivars(obj, ivtbl)) != 0) { - w_byte(TYPE_IVAR, arg); - } if (obj == Qnil) { w_byte(TYPE_NIL, arg); } @@ -646,6 +643,8 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) v = rb_funcall(obj, s_mdump, 0, 0); check_dump_arg(arg, s_mdump); + hasiv = has_ivars(obj, ivtbl); + if (hasiv) w_byte(TYPE_IVAR, arg); w_class(TYPE_USRMARSHAL, obj, arg, FALSE); w_object(v, arg, limit); if (hasiv) w_ivar(obj, ivtbl, &c_arg); @@ -661,6 +660,8 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) if (TYPE(v) != T_STRING) { rb_raise(rb_eTypeError, "_dump() must return string"); } + hasiv = has_ivars(obj, ivtbl); + if (hasiv) w_byte(TYPE_IVAR, arg); if ((hasiv2 = has_ivars(v, ivtbl2)) != 0 && !hasiv) { w_byte(TYPE_IVAR, arg); } @@ -678,6 +679,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) st_add_direct(arg->data, obj, arg->data->num_entries); + hasiv = has_ivars(obj, ivtbl); { st_data_t compat_data; rb_alloc_func_t allocator = rb_get_alloc_func(RBASIC(obj)->klass); @@ -688,8 +690,10 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) VALUE real_obj = obj; obj = compat->dumper(real_obj); st_insert(arg->compat_tbl, (st_data_t)obj, (st_data_t)real_obj); + if (obj != real_obj && !ivtbl) hasiv = 0; } } + if (hasiv) w_byte(TYPE_IVAR, arg); switch (BUILTIN_TYPE(obj)) { case T_CLASS: