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: canonicalizes nth and sf.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2011-07-10 05:59:12 +00:00
parent 919978a8d9
commit 32af4ed47f
2 changed files with 21 additions and 6 deletions

View file

@ -1,3 +1,7 @@
Sun Jul 10 14:57:36 2011 Tadayoshi Funaba <tadf@dotrb.org>
* ext/date/date_core.c: canonicalizes nth and sf.
Sun Jul 10 14:13:50 2011 Koichi Sasada <ko1@atdot.net>
* internal.h (rb_thread_call_with_gvl, rb_thread_call_without_gvl):

View file

@ -308,10 +308,21 @@ union DateData {
Data_Get_Struct(x, union DateData, adat);\
Data_Get_Struct(y, union DateData, bdat);
inline static VALUE
canon(VALUE x)
{
if (TYPE(x) == T_RATIONAL) {
VALUE den = RRATIONAL(x)->den;
if (FIXNUM_P(den) && FIX2LONG(den) == 1)
return RRATIONAL(x)->num;
}
return x;
}
#ifndef USE_PACK
#define set_to_simple(x, _nth, _jd ,_sg, _year, _mon, _mday, _flags) \
{\
(x)->nth = _nth;\
(x)->nth = canon(_nth);\
(x)->jd = _jd;\
(x)->sg = (sg_cast)(_sg);\
(x)->year = _year;\
@ -322,7 +333,7 @@ union DateData {
#else
#define set_to_simple(x, _nth, _jd ,_sg, _year, _mon, _mday, _flags) \
{\
(x)->nth = _nth;\
(x)->nth = canon(_nth);\
(x)->jd = _jd;\
(x)->sg = (sg_cast)(_sg);\
(x)->year = _year;\
@ -335,10 +346,10 @@ union DateData {
#define set_to_complex(x, _nth, _jd ,_df, _sf, _of, _sg,\
_year, _mon, _mday, _hour, _min, _sec, _flags) \
{\
(x)->nth = _nth;\
(x)->nth = canon(_nth);\
(x)->jd = _jd;\
(x)->df = _df;\
(x)->sf = _sf;\
(x)->sf = canon(_sf);\
(x)->of = _of;\
(x)->sg = (sg_cast)(_sg);\
(x)->year = _year;\
@ -353,10 +364,10 @@ _year, _mon, _mday, _hour, _min, _sec, _flags) \
#define set_to_complex(x, _nth, _jd ,_df, _sf, _of, _sg,\
_year, _mon, _mday, _hour, _min, _sec, _flags) \
{\
(x)->nth = _nth;\
(x)->nth = canon(_nth);\
(x)->jd = _jd;\
(x)->df = _df;\
(x)->sf = _sf;\
(x)->sf = canon(_sf);\
(x)->of = _of;\
(x)->sg = (sg_cast)(_sg);\
(x)->year = _year;\