Project

General

Profile

Bug #5171 » 0001-ext-date-date_core.c-d_lite_inspect-RB_GC_GUARD-temp.patch

normalperson (Eric Wong), 08/09/2011 07:30 AM

View differences:

ext/date/date_core.c
static VALUE
mk_inspect(union DateData *x, const char *klass, const char *to_s)
{
VALUE real_jd = f_inspect(m_real_jd(x));
VALUE sf = f_inspect(m_sf(x));
RB_GC_GUARD(real_jd);
RB_GC_GUARD(sf);
return rb_enc_sprintf(rb_usascii_encoding(),
"#<%s: %s ((%sj,%ds,%sn),%+ds,%.0fj)>",
klass ? klass : "?",
to_s ? to_s : "?",
RSTRING_PTR(f_inspect(m_real_jd(x))), m_df(x),
RSTRING_PTR(f_inspect(m_sf(x))),
RSTRING_PTR(real_jd), m_df(x),
RSTRING_PTR(sf),
m_of(x), m_sg(x));
}
......
static VALUE
d_lite_inspect(VALUE self)
{
VALUE to_s;
get_d1(self);
return mk_inspect(dat, rb_obj_classname(self),
RSTRING_PTR(f_to_s(self)));
to_s = f_to_s(self);
RB_GC_GUARD(to_s);
return mk_inspect(dat, rb_obj_classname(self), RSTRING_PTR(to_s));
}
#include <errno.h>
test/date/test_date.rb
assert_instance_of(String, d.to_s)
end
def test_gc
stress, GC.stress = GC.stress, true
5.times do
Date.new(1965, 5, 23).inspect.gsub!(/./, '')
DateTime.new(1965, 5, 23, 22, 31, 59).inspect.gsub!(/./, '')
end
ensure
GC.stress = stress
end
end
(1-1/2)