ruby-changes:19142
From: tadf <ko1@a...>
Date: Fri, 25 Mar 2011 22:01:14 +0900 (JST)
Subject: [ruby-changes:19142] Ruby:r31181 (trunk): * ext/date/date_core.c: should not force cast with macros.
tadf 2011-03-25 22:01:06 +0900 (Fri, 25 Mar 2011) New Revision: 31181 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31181 Log: * ext/date/date_core.c: should not force cast with macros. Modified files: trunk/ChangeLog trunk/ext/date/date_core.c trunk/ext/date/date_strftime.c Index: ChangeLog =================================================================== --- ChangeLog (revision 31180) +++ ChangeLog (revision 31181) @@ -1,3 +1,7 @@ +Fri Mar 25 21:59:45 2011 Tadayoshi Funaba <tadf@d...> + + * ext/date/date_core.c: should not force cast with macros. + Fri Mar 25 21:56:10 2011 Tanaka Akira <akr@f...> * ext/sdbm/init.c: parenthesize macro arguments. Index: ext/date/date_core.c =================================================================== --- ext/date/date_core.c (revision 31180) +++ ext/date/date_core.c (revision 31181) @@ -42,10 +42,10 @@ #define DAY_IN_NANOSECONDS 86400000000000LL /* copied from time.c */ -#define NDIV(x,y) ((int)(-(-((x)+1)/(y))-1)) -#define NMOD(x,y) ((int)((y)-(-((x)+1)%(y))-1)) -#define DIV(n,d) ((int)((n)<0 ? NDIV((n),(d)) : (n)/(d))) -#define MOD(n,d) ((int)((n)<0 ? NMOD((n),(d)) : (n)%(d))) +#define NDIV(x,y) (-(-((x)+1)/(y))-1) +#define NMOD(x,y) ((y)-(-((x)+1)%(y))-1) +#define DIV(n,d) ((n)<0 ? NDIV((n),(d)) : (n)/(d)) +#define MOD(n,d) ((n)<0 ? NMOD((n),(d)) : (n)%(d)) union DateData { @@ -338,8 +338,8 @@ commercial_to_jd(a, 1, 1, sg, &rjd2, &ns2); *ry = a; } - *rw = 1 + DIV(jd - rjd2, 7); - *rd = MOD(jd + 1, 7); + *rw = 1 + (int)DIV(jd - rjd2, 7); + *rd = (int)MOD(jd + 1, 7); if (*rd == 0) *rd = 7; } @@ -368,8 +368,8 @@ find_fdoy(*ry, sg, &rjd, &ns); rjd += 6; j = jd - (rjd - MOD((rjd - f) + 1, 7)) + 7; - *rw = DIV(j, 7); - *rd = MOD(j, 7); + *rw = (int)DIV(j, 7); + *rd = (int)MOD(j, 7); } #ifndef NDEBUG @@ -403,7 +403,7 @@ jd_to_civil(jd, sg, ry, rm, &rd); find_fdom(*ry, *rm, sg, &rjd, &ns2); - *rn = DIV(jd - rjd, 7) + 1; + *rn = (int)DIV(jd - rjd, 7) + 1; *rk = jd_to_wday(jd); } #endif @@ -585,7 +585,7 @@ inline static int jd_to_wday(long jd) { - return MOD(jd + 1, 7); + return (int)MOD(jd + 1, 7); } static int Index: ext/date/date_strftime.c =================================================================== --- ext/date/date_strftime.c (revision 31180) +++ ext/date/date_strftime.c (revision 31181) @@ -487,13 +487,14 @@ case 'z': /* time zone offset east of GMT e.g. -0600 */ SKIP_MODIFIER_EO; { - int aoff, hl, hw; + long aoff; + int hl, hw; off = NUM2LONG(rb_funcall(vtm->utc_offset, rb_intern("round"), 0)); - aoff = (int)off; + aoff = off; if (aoff < 0) - aoff = (int)-off; + aoff = -off; if ((aoff / 3600) < 10) hl = 1; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/