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

* ext/date/date_core.c: [ruby-core:38861]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2011-08-13 08:05:43 +00:00
parent a49ad9a639
commit 75de442dd0
2 changed files with 32 additions and 11 deletions

View file

@ -1,3 +1,7 @@
Sat Aug 13 17:03:22 2011 Tadayoshi Funaba <tadf@dotrb.org>
* ext/date/date_core.c: [ruby-core:38861]
Sat Aug 13 09:39:07 2011 Tadayoshi Funaba <tadf@dotrb.org> Sat Aug 13 09:39:07 2011 Tadayoshi Funaba <tadf@dotrb.org>
* test/date/test_*.rb: added tests. * test/date/test_*.rb: added tests.

View file

@ -6609,30 +6609,39 @@ static VALUE
mk_inspect_raw(union DateData *x, const char *klass) mk_inspect_raw(union DateData *x, const char *klass)
{ {
if (simple_dat_p(x)) { if (simple_dat_p(x)) {
VALUE nth, flags;
RB_GC_GUARD(nth) = f_inspect(x->s.nth);
RB_GC_GUARD(flags) = mk_inspect_flags(x);
return rb_enc_sprintf(rb_usascii_encoding(), return rb_enc_sprintf(rb_usascii_encoding(),
"#<%s: " "#<%s: "
"(%sth,%dj),+0s,%.0fj; " "(%sth,%dj),+0s,%.0fj; "
"%dy%dm%dd; %s>", "%dy%dm%dd; %s>",
klass ? klass : "?", klass ? klass : "?",
RSTRING_PTR(f_inspect(x->s.nth)), RSTRING_PTR(nth), x->s.jd, x->s.sg,
x->s.jd, x->s.sg,
#ifndef USE_PACK #ifndef USE_PACK
x->s.year, x->s.mon, x->s.mday, x->s.year, x->s.mon, x->s.mday,
#else #else
x->s.year, x->s.year,
EX_MON(x->s.pc), EX_MDAY(x->s.pc), EX_MON(x->s.pc), EX_MDAY(x->s.pc),
#endif #endif
RSTRING_PTR(mk_inspect_flags(x))); RSTRING_PTR(flags));
} }
else { else {
VALUE nth, sf, flags;
RB_GC_GUARD(nth) = f_inspect(x->c.nth);
RB_GC_GUARD(sf) = f_inspect(x->c.sf);
RB_GC_GUARD(flags) = mk_inspect_flags(x);
return rb_enc_sprintf(rb_usascii_encoding(), return rb_enc_sprintf(rb_usascii_encoding(),
"#<%s: " "#<%s: "
"(%sth,%dj,%ds,%sn),%+ds,%.0fj; " "(%sth,%dj,%ds,%sn),%+ds,%.0fj; "
"%dy%dm%dd %dh%dm%ds; %s>", "%dy%dm%dd %dh%dm%ds; %s>",
klass ? klass : "?", klass ? klass : "?",
RSTRING_PTR(f_inspect(x->c.nth)), RSTRING_PTR(nth), x->c.jd, x->c.df,
x->c.jd, x->c.df, RSTRING_PTR(sf),
RSTRING_PTR(f_inspect(x->c.sf)),
x->c.of, x->c.sg, x->c.of, x->c.sg,
#ifndef USE_PACK #ifndef USE_PACK
x->c.year, x->c.mon, x->c.mday, x->c.year, x->c.mon, x->c.mday,
@ -6643,7 +6652,7 @@ mk_inspect_raw(union DateData *x, const char *klass)
EX_HOUR(x->c.pc), EX_MIN(x->c.pc), EX_HOUR(x->c.pc), EX_MIN(x->c.pc),
EX_SEC(x->c.pc), EX_SEC(x->c.pc),
#endif #endif
RSTRING_PTR(mk_inspect_flags(x))); RSTRING_PTR(flags));
} }
} }
@ -6658,12 +6667,16 @@ d_lite_inspect_raw(VALUE self)
static VALUE static VALUE
mk_inspect(union DateData *x, const char *klass, const char *to_s) mk_inspect(union DateData *x, const char *klass, const char *to_s)
{ {
VALUE jd, sf;
RB_GC_GUARD(jd) = f_inspect(m_real_jd(x));
RB_GC_GUARD(sf) = f_inspect(m_sf(x));
return rb_enc_sprintf(rb_usascii_encoding(), return rb_enc_sprintf(rb_usascii_encoding(),
"#<%s: %s ((%sj,%ds,%sn),%+ds,%.0fj)>", "#<%s: %s ((%sj,%ds,%sn),%+ds,%.0fj)>",
klass ? klass : "?", klass ? klass : "?",
to_s ? to_s : "?", to_s ? to_s : "?",
RSTRING_PTR(f_inspect(m_real_jd(x))), m_df(x), RSTRING_PTR(jd), m_df(x), RSTRING_PTR(sf),
RSTRING_PTR(f_inspect(m_sf(x))),
m_of(x), m_sg(x)); m_of(x), m_sg(x));
} }
@ -6685,8 +6698,12 @@ static VALUE
d_lite_inspect(VALUE self) d_lite_inspect(VALUE self)
{ {
get_d1(self); get_d1(self);
return mk_inspect(dat, rb_obj_classname(self), {
RSTRING_PTR(f_to_s(self))); VALUE to_s;
RB_GC_GUARD(to_s) = f_to_s(self);
return mk_inspect(dat, rb_obj_classname(self), RSTRING_PTR(to_s));
}
} }
#include <errno.h> #include <errno.h>