ruby-changes:22023
From: tadf <ko1@a...>
Date: Tue, 20 Dec 2011 02:17:04 +0900 (JST)
Subject: [ruby-changes:22023] tadf:r34072 (trunk): * ext/date/date_core.c: .
tadf 2011-12-20 02:16:48 +0900 (Tue, 20 Dec 2011) New Revision: 34072 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34072 Log: * ext/date/date_core.c: [ruby-dev:45008]. Modified files: trunk/ChangeLog trunk/ext/date/date_core.c Index: ChangeLog =================================================================== --- ChangeLog (revision 34071) +++ ChangeLog (revision 34072) @@ -1,3 +1,7 @@ +Tue Dec 20 02:15:18 2011 Tadayoshi Funaba <tadf@d...> + + * ext/date/date_core.c: [ruby-dev:45008]. + Sun Dec 18 18:52:37 2011 Naohisa Goto <ngotogenome@g...> * vm.c (vm_define_method): improve guard of iseq from GC. Fix Index: ext/date/date_core.c =================================================================== --- ext/date/date_core.c (revision 34071) +++ ext/date/date_core.c (revision 34072) @@ -39,6 +39,7 @@ #define f_truncate(x) rb_funcall(x, rb_intern("truncate"), 0) #define f_round(x) rb_funcall(x, rb_intern("round"), 0) +#define f_to_i(x) rb_funcall(x, rb_intern("to_i"), 0) #define f_to_r(x) rb_funcall(x, rb_intern("to_r"), 0) #define f_to_s(x) rb_funcall(x, rb_intern("to_s"), 0) #define f_inspect(x) rb_funcall(x, rb_intern("inspect"), 0) @@ -3094,13 +3095,25 @@ return 0; } +inline static int +wholenum(VALUE x) +{ + if (FIXNUM_P(x)) + return x; + switch (TYPE(x)) { + case T_BIGNUM: + return x; + } + return f_to_i(x); +} + inline static VALUE d_trunc(VALUE d, VALUE *fr) { VALUE rd; if (wholenum_p(d)) { - rd = d; + rd = wholenum(d); *fr = INT2FIX(0); } else { rd = f_idiv(d, INT2FIX(1)); @@ -3118,7 +3131,7 @@ VALUE rh; if (wholenum_p(h)) { - rh = h; + rh = wholenum(h); *fr = INT2FIX(0); } else { rh = f_idiv(h, INT2FIX(1)); @@ -3134,7 +3147,7 @@ VALUE rmin; if (wholenum_p(min)) { - rmin = min; + rmin = wholenum(min); *fr = INT2FIX(0); } else { rmin = f_idiv(min, INT2FIX(1)); @@ -3150,7 +3163,7 @@ VALUE rs; if (wholenum_p(s)) { - rs = s; + rs = wholenum(s); *fr = INT2FIX(0); } else { rs = f_idiv(s, INT2FIX(1)); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/