summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--complex.c7
-rw-r--r--rational.c7
-rw-r--r--test/ruby/test_complex.rb2
-rw-r--r--test/ruby/test_rational.rb2
5 files changed, 24 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 5698062c42..d4098ce612 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Sep 16 19:18:40 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c (nucomp_marshal_{dump,load}): preserve instance
+ variables.
+
+ * rational.c (nurat_marshal_{dump,load}): ditto.
+
Tue Sep 16 18:28:52 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_gets_m): rdoc updated. limit counts in bytes.
@@ -251,7 +258,7 @@ Sun Sep 14 13:48:03 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
Sun Sep 14 10:10:43 2008 Tadayoshi Funaba <tadf@dotrb.org>
- * complex.c (f_{add,mul,sub}): omitted some shortcuts for preserve
+ * complex.c (f_{add,mul,sub}): omitted some shortcuts for preserving
signed zero anyway.
* complex.c (nucomp_negate): new.
diff --git a/complex.c b/complex.c
index 1739cc12b1..0ed8a2c45c 100644
--- a/complex.c
+++ b/complex.c
@@ -937,8 +937,12 @@ nucomp_inspect(VALUE self)
static VALUE
nucomp_marshal_dump(VALUE self)
{
+ VALUE a;
get_dat1(self);
- return rb_assoc_new(dat->real, dat->image);
+
+ a = rb_assoc_new(dat->real, dat->image);
+ rb_copy_generic_ivar(a, self);
+ return a;
}
static VALUE
@@ -947,6 +951,7 @@ nucomp_marshal_load(VALUE self, VALUE a)
get_dat1(self);
dat->real = RARRAY_PTR(a)[0];
dat->image = RARRAY_PTR(a)[1];
+ rb_copy_generic_ivar(self, a);
return self;
}
diff --git a/rational.c b/rational.c
index 5669a7beb6..a592ae31e9 100644
--- a/rational.c
+++ b/rational.c
@@ -1125,8 +1125,12 @@ nurat_inspect(VALUE self)
static VALUE
nurat_marshal_dump(VALUE self)
{
+ VALUE a;
get_dat1(self);
- return rb_assoc_new(dat->num, dat->den);
+
+ a = rb_assoc_new(dat->num, dat->den);
+ rb_copy_generic_ivar(a, self);
+ return a;
}
static VALUE
@@ -1135,6 +1139,7 @@ nurat_marshal_load(VALUE self, VALUE a)
get_dat1(self);
dat->num = RARRAY_PTR(a)[0];
dat->den = RARRAY_PTR(a)[1];
+ rb_copy_generic_ivar(self, a);
if (f_zero_p(dat->den))
rb_raise_zerodiv();
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb
index 493e2e2c39..af2311ca00 100644
--- a/test/ruby/test_complex.rb
+++ b/test/ruby/test_complex.rb
@@ -638,10 +638,12 @@ class Complex_Test < Test::Unit::TestCase
def test_marshal
c = Complex(1,2)
+ c.instance_eval{@ivar = 9}
s = Marshal.dump(c)
c2 = Marshal.load(s)
assert_equal(c, c2)
+ assert_equal(9, c2.instance_variable_get(:@ivar))
assert_instance_of(Complex, c2)
if defined?(Rational)
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index 1d280e4361..de8c31dbc5 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -854,10 +854,12 @@ class Rational_Test < Test::Unit::TestCase
def test_marshal
c = Rational(1,2)
+ c.instance_eval{@ivar = 9}
s = Marshal.dump(c)
c2 = Marshal.load(s)
assert_equal(c, c2)
+ assert_equal(9, c2.instance_variable_get(:@ivar))
assert_instance_of(Rational, c2)
assert_raise(ZeroDivisionError){