summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-26 14:35:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-26 14:35:30 +0000
commitfe060e0e5c8d5521c1e8c8022af7d3217f48f8fa (patch)
treed45dbcfb32727c0ba491df4d25f5804151f61376
parent7063546d64397af5a9352f8a8a78334223c39c04 (diff)
* ext/date/date_core.c: adjust indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/date/date_core.c322
1 files changed, 161 insertions, 161 deletions
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index f6d1f74b711..917da6c62a8 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -600,56 +600,56 @@ daydiff_to_sec(VALUE vof, int *rof)
{
switch (TYPE(vof)) {
case T_FIXNUM:
- {
- int n;
-
- n = FIX2INT(vof);
- if (n != -1 && n != 0 && n != 1)
- return 0;
- *rof = n * DAY_IN_SECONDS;
- return 1;
- }
+ {
+ int n;
+
+ n = FIX2INT(vof);
+ if (n != -1 && n != 0 && n != 1)
+ return 0;
+ *rof = n * DAY_IN_SECONDS;
+ return 1;
+ }
case T_FLOAT:
- {
- double n;
-
- n = NUM2DBL(vof);
- if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)
- return 0;
- *rof = round(n * DAY_IN_SECONDS);
- return 1;
- }
+ {
+ double n;
+
+ n = NUM2DBL(vof);
+ if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)
+ return 0;
+ *rof = round(n * DAY_IN_SECONDS);
+ return 1;
+ }
case T_RATIONAL:
- {
- VALUE vs = f_mul(vof, INT2FIX(DAY_IN_SECONDS));
- VALUE vn = RRATIONAL(vs)->num;
- VALUE vd = RRATIONAL(vs)->den;
- int n, d;
-
- if (!FIXNUM_P(vn) || !FIXNUM_P(vd))
- return 0;
- n = FIX2INT(vn);
- d = FIX2INT(vd);
- if (d != 1)
- return 0;
- if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)
- return 0;
- *rof = n;
- return 1;
- }
+ {
+ VALUE vs = f_mul(vof, INT2FIX(DAY_IN_SECONDS));
+ VALUE vn = RRATIONAL(vs)->num;
+ VALUE vd = RRATIONAL(vs)->den;
+ int n, d;
+
+ if (!FIXNUM_P(vn) || !FIXNUM_P(vd))
+ return 0;
+ n = FIX2INT(vn);
+ d = FIX2INT(vd);
+ if (d != 1)
+ return 0;
+ if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)
+ return 0;
+ *rof = n;
+ return 1;
+ }
case T_STRING:
- {
- VALUE vs = rb_funcall(cDate, rb_intern("zone_to_diff"), 1, vof);
- int n;
-
- if (!FIXNUM_P(vs))
- return 0;
- n = FIX2INT(vs);
- if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)
- return 0;
- *rof = n;
- return 1;
- }
+ {
+ VALUE vs = rb_funcall(cDate, rb_intern("zone_to_diff"), 1, vof);
+ int n;
+
+ if (!FIXNUM_P(vs))
+ return 0;
+ n = FIX2INT(vs);
+ if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)
+ return 0;
+ *rof = n;
+ return 1;
+ }
}
return 0;
}
@@ -1666,28 +1666,28 @@ d_lite_plus(VALUE self, VALUE other)
switch (TYPE(other)) {
case T_FIXNUM:
- {
- long jd;
+ {
+ long jd;
- get_d_jd(dat);
+ get_d_jd(dat);
- jd = dat->l.jd + FIX2LONG(other);
+ jd = dat->l.jd + FIX2LONG(other);
- if (LIGHTABLE_JD(jd) && jd >= dat->l.sg)
- return d_lite_s_new_internal(CLASS_OF(self),
- jd, dat->l.sg,
- 0, 0, 0,
- dat->l.flags & ~HAVE_CIVIL);
- }
- break;
+ if (LIGHTABLE_JD(jd) && jd >= dat->l.sg)
+ return d_lite_s_new_internal(CLASS_OF(self),
+ jd, dat->l.sg,
+ 0, 0, 0,
+ dat->l.flags & ~HAVE_CIVIL);
+ }
+ break;
case T_FLOAT:
- {
- double d = NUM2DBL(other);
- long l = round(d);
- if (l == d && LIGHTABLE_JD(l))
- return d_lite_plus(self, INT2FIX(l));
- }
- break;
+ {
+ double d = NUM2DBL(other);
+ long l = round(d);
+ if (l == d && LIGHTABLE_JD(l))
+ return d_lite_plus(self, INT2FIX(l));
+ }
+ break;
}
return iforwardop("plus_r");
}
@@ -1758,7 +1758,7 @@ d_lite_minus(VALUE self, VALUE other)
d = adat->l.jd - bdat->l.jd;
return rb_rational_new1(LONG2NUM(d));
}
- }
+ }
switch (TYPE(other)) {
case T_FIXNUM:
@@ -2948,102 +2948,102 @@ dt_lite_plus(VALUE self, VALUE other)
switch (TYPE(other)) {
case T_FIXNUM:
- {
- long jd;
-
- get_dt1(self);
- get_dt_jd(dat);
- get_dt_df(dat);
-
- jd = dat->l.jd + FIX2LONG(other);
-
- if (LIGHTABLE_JD(jd) && jd >= dat->l.sg)
- return dt_lite_s_new_internal(CLASS_OF(self),
- jd,
- dat->l.df,
- dat->l.sf,
- dat->l.of,
- dat->l.sg,
- 0, 0, 0,
- dat->l.hour,
- dat->l.min,
- dat->l.sec,
- dat->l.flags & ~HAVE_CIVIL);
- }
- break;
+ {
+ long jd;
+
+ get_dt1(self);
+ get_dt_jd(dat);
+ get_dt_df(dat);
+
+ jd = dat->l.jd + FIX2LONG(other);
+
+ if (LIGHTABLE_JD(jd) && jd >= dat->l.sg)
+ return dt_lite_s_new_internal(CLASS_OF(self),
+ jd,
+ dat->l.df,
+ dat->l.sf,
+ dat->l.of,
+ dat->l.sg,
+ 0, 0, 0,
+ dat->l.hour,
+ dat->l.min,
+ dat->l.sec,
+ dat->l.flags & ~HAVE_CIVIL);
+ }
+ break;
case T_FLOAT:
- {
- long jd, df;
- long long sf;
- long double o;
- int s;
-
- get_dt1(self);
- get_dt_jd(dat);
- get_dt_df(dat);
-
- jd = dat->l.jd;
- o = NUM2DBL(other);
-
- if (o < 0) {
- s = -1;
- o = -o;
- }
- else
- s = +1;
-
- jd = (long)floorl(o);
- o = o - jd;
- o *= DAY_IN_SECONDS;
- df = (long)floorl(o);
- o = o - df;
- o *= SECOND_IN_NANOSECONDS;
- sf = (long)roundl(o);
-
- if (s < 0) {
- jd = -jd;
- df = -df;
- sf = -sf;
- }
-
- sf = dat->l.sf + sf;
- if (sf < 0) {
- df -= 1;
- sf += SECOND_IN_NANOSECONDS;
- }
- else if (sf >= SECOND_IN_NANOSECONDS) {
- df += 1;
- sf -= SECOND_IN_NANOSECONDS;
- }
-
- df = dat->l.df + df;
- if (df < 0) {
- jd -= 1;
- df += DAY_IN_SECONDS;
- }
- else if (df >= DAY_IN_SECONDS) {
- jd += 1;
- df -= DAY_IN_SECONDS;
- }
-
- jd = dat->l.jd + jd;
-
- if (LIGHTABLE_JD(jd) && jd >= dat->l.sg)
- return dt_lite_s_new_internal(CLASS_OF(self),
- jd,
- df,
- sf,
- dat->l.of,
- dat->l.sg,
- 0, 0, 0,
- dat->l.hour,
- dat->l.min,
- dat->l.sec,
- dat->l.flags &
- ~HAVE_CIVIL &
- ~HAVE_TIME);
- }
- break;
+ {
+ long jd, df;
+ long long sf;
+ long double o;
+ int s;
+
+ get_dt1(self);
+ get_dt_jd(dat);
+ get_dt_df(dat);
+
+ jd = dat->l.jd;
+ o = NUM2DBL(other);
+
+ if (o < 0) {
+ s = -1;
+ o = -o;
+ }
+ else
+ s = +1;
+
+ jd = (long)floorl(o);
+ o = o - jd;
+ o *= DAY_IN_SECONDS;
+ df = (long)floorl(o);
+ o = o - df;
+ o *= SECOND_IN_NANOSECONDS;
+ sf = (long)roundl(o);
+
+ if (s < 0) {
+ jd = -jd;
+ df = -df;
+ sf = -sf;
+ }
+
+ sf = dat->l.sf + sf;
+ if (sf < 0) {
+ df -= 1;
+ sf += SECOND_IN_NANOSECONDS;
+ }
+ else if (sf >= SECOND_IN_NANOSECONDS) {
+ df += 1;
+ sf -= SECOND_IN_NANOSECONDS;
+ }
+
+ df = dat->l.df + df;
+ if (df < 0) {
+ jd -= 1;
+ df += DAY_IN_SECONDS;
+ }
+ else if (df >= DAY_IN_SECONDS) {
+ jd += 1;
+ df -= DAY_IN_SECONDS;
+ }
+
+ jd = dat->l.jd + jd;
+
+ if (LIGHTABLE_JD(jd) && jd >= dat->l.sg)
+ return dt_lite_s_new_internal(CLASS_OF(self),
+ jd,
+ df,
+ sf,
+ dat->l.of,
+ dat->l.sg,
+ 0, 0, 0,
+ dat->l.hour,
+ dat->l.min,
+ dat->l.sec,
+ dat->l.flags &
+ ~HAVE_CIVIL &
+ ~HAVE_TIME);
+ }
+ break;
}
return iforwardop("plus_r");
}