From cdf40ecbd88c9ef9f758d3bd6376668f2e4722b3 Mon Sep 17 00:00:00 2001 From: michal Date: Wed, 23 Jun 2004 12:59:01 +0000 Subject: Fix indentation in time.c Move stack-len info from main.c to gc.c git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 ++ gc.c | 10 +- main.c | 12 -- time.c | 530 +++++++++++++++++++++++++++++++------------------------------- 4 files changed, 278 insertions(+), 283 deletions(-) diff --git a/ChangeLog b/ChangeLog index af01a6af74..18fa55d4e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Jun 23 21:48:27 2004 Michal Rokos + + * time.c: Fix indentation. + + * main.c: Remove _stklen, and _CRT_glob. Move _stacksize for + __human68k__ to gc.c where the others are. + + * gc.c: put _stacksize in place and clean the #ifdefs macros. + Wed Jun 23 17:37:54 2004 Shugo Maeda * lib/net/imap.rb: added new option --ssl. diff --git a/gc.c b/gc.c index a364b33268..871f60b85e 100644 --- a/gc.c +++ b/gc.c @@ -407,19 +407,15 @@ VALUE *rb_gc_stack_start = 0; #if defined(DJGPP) || defined(_WIN32_WCE) static unsigned int STACK_LEVEL_MAX = 65535; -#else -#ifdef __human68k__ -extern unsigned int _stacksize; +#elif defined(__human68k__) +unsigned int _stacksize = 262144; # define STACK_LEVEL_MAX (_stacksize - 4096) # undef HAVE_GETRLIMIT -#else -#ifdef HAVE_GETRLIMIT +#elif defined(HAVE_GETRLIMIT) static unsigned int STACK_LEVEL_MAX = 655300; #else # define STACK_LEVEL_MAX 655300 #endif -#endif -#endif #ifdef C_ALLOCA # define SET_STACK_END VALUE stack_end; alloca(0); diff --git a/main.c b/main.c index aa264e8507..cffbe25120 100644 --- a/main.c +++ b/main.c @@ -12,18 +12,6 @@ #include "ruby.h" -#ifdef DJGPP -unsigned int _stklen = 0x180000; -#endif - -#ifdef __human68k__ -int _stacksize = 262144; -#endif - -#if defined __MINGW32__ -int _CRT_glob = 0; -#endif - #if defined(__MACOS__) && defined(__MWERKS__) #include #endif diff --git a/time.c b/time.c index abf2967b32..47e3be1e17 100644 --- a/time.c +++ b/time.c @@ -376,19 +376,17 @@ time_arg(argc, argv, tm, usec) tm->tm_min = NIL_P(v[4])?0:obj2long(v[4]); tm->tm_sec = NIL_P(v[5])?0:obj2long(v[5]); if (!NIL_P(v[6])) { - if (argc == 8) { - /* v[6] is timezone, but ignored */ - } - else if (argc == 7) { + /* when argc == 8, v[6] is timezone, but ignored */ + if (argc == 7) { *usec = obj2long(v[6]); } } /* value validation */ if ( - tm->tm_year != year || + tm->tm_year != year || #ifndef NEGATIVE_TIME_T - tm->tm_year < 69 || + tm->tm_year < 69 || #endif tm->tm_mon < 0 || tm->tm_mon > 11 || tm->tm_mday < 1 || tm->tm_mday > 31 @@ -406,7 +404,7 @@ static int leap_year_p(y) long y; { - return ((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0); + return ((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0); } #define DIV(n,d) ((n)<0 ? NDIV((n),(d)) : (n)/(d)) @@ -416,42 +414,42 @@ timegm_noleapsecond(tm) struct tm *tm; { static int common_year_yday_offset[] = { - -1, - -1 + 31, - -1 + 31 + 28, - -1 + 31 + 28 + 31, - -1 + 31 + 28 + 31 + 30, - -1 + 31 + 28 + 31 + 30 + 31, - -1 + 31 + 28 + 31 + 30 + 31 + 30, - -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31, - -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31, - -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30, - -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31, - -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 - /* 1 2 3 4 5 6 7 8 9 10 11 */ + -1, + -1 + 31, + -1 + 31 + 28, + -1 + 31 + 28 + 31, + -1 + 31 + 28 + 31 + 30, + -1 + 31 + 28 + 31 + 30 + 31, + -1 + 31 + 28 + 31 + 30 + 31 + 30, + -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31, + -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31, + -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30, + -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31, + -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + /* 1 2 3 4 5 6 7 8 9 10 11 */ }; static int leap_year_yday_offset[] = { - -1, - -1 + 31, - -1 + 31 + 29, - -1 + 31 + 29 + 31, - -1 + 31 + 29 + 31 + 30, - -1 + 31 + 29 + 31 + 30 + 31, - -1 + 31 + 29 + 31 + 30 + 31 + 30, - -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31, - -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31, - -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30, - -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31, - -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 - /* 1 2 3 4 5 6 7 8 9 10 11 */ + -1, + -1 + 31, + -1 + 31 + 29, + -1 + 31 + 29 + 31, + -1 + 31 + 29 + 31 + 30, + -1 + 31 + 29 + 31 + 30 + 31, + -1 + 31 + 29 + 31 + 30 + 31 + 30, + -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31, + -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31, + -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30, + -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31, + -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + /* 1 2 3 4 5 6 7 8 9 10 11 */ }; long tm_year = tm->tm_year; int tm_yday = tm->tm_mday; if (leap_year_p(tm_year + 1900)) - tm_yday += leap_year_yday_offset[tm->tm_mon]; + tm_yday += leap_year_yday_offset[tm->tm_mon]; else - tm_yday += common_year_yday_offset[tm->tm_mon]; + tm_yday += common_year_yday_offset[tm->tm_mon]; /* * `Seconds Since the Epoch' in SUSv3: @@ -460,11 +458,11 @@ timegm_noleapsecond(tm) * ((tm_year-1)/100)*86400 + ((tm_year+299)/400)*86400 */ return tm->tm_sec + tm->tm_min*60 + tm->tm_hour*3600 + - (time_t)(tm_yday + - (tm_year-70)*365 + - DIV(tm_year-69,4) - - DIV(tm_year-1,100) + - DIV(tm_year+299,400))*86400; + (time_t)(tm_yday + + (tm_year-70)*365 + + DIV(tm_year-69,4) - + DIV(tm_year-1,100) + + DIV(tm_year+299,400))*86400; } static int @@ -473,17 +471,17 @@ tmcmp(a, b) struct tm *b; { if (a->tm_year != b->tm_year) - return a->tm_year < b->tm_year ? -1 : 1; + return a->tm_year < b->tm_year ? -1 : 1; else if (a->tm_mon != b->tm_mon) - return a->tm_mon < b->tm_mon ? -1 : 1; + return a->tm_mon < b->tm_mon ? -1 : 1; else if (a->tm_mday != b->tm_mday) - return a->tm_mday < b->tm_mday ? -1 : 1; + return a->tm_mday < b->tm_mday ? -1 : 1; else if (a->tm_hour != b->tm_hour) - return a->tm_hour < b->tm_hour ? -1 : 1; + return a->tm_hour < b->tm_hour ? -1 : 1; else if (a->tm_min != b->tm_min) - return a->tm_min < b->tm_min ? -1 : 1; + return a->tm_min < b->tm_min ? -1 : 1; else if (a->tm_sec != b->tm_sec) - return a->tm_sec < b->tm_sec ? -1 : 1; + return a->tm_sec < b->tm_sec ? -1 : 1; else return 0; } @@ -506,31 +504,31 @@ search_time_t(tptr, utc_p) guess_lo = 0; #endif guess_hi = ((time_t)-1) < ((time_t)0) ? - (1UL << (8 * sizeof(time_t) - 1)) - 1 : + (1UL << (8 * sizeof(time_t) - 1)) - 1 : ~(time_t)0; guess = timegm_noleapsecond(tptr); tm = (utc_p ? gmtime : localtime)(&guess); if (tm) { - d = tmcmp(tptr, tm); - if (d == 0) return guess; - if (d < 0) { - guess_hi = guess; - guess -= 24 * 60 * 60; - } - else { - guess_lo = guess; - guess += 24 * 60 * 60; - } - if (guess_lo < guess && guess < guess_hi && - (tm = (utc_p ? gmtime : localtime)(&guess)) != NULL) { - d = tmcmp(tptr, tm); - if (d == 0) return guess; - if (d < 0) - guess_hi = guess; - else - guess_lo = guess; - } + d = tmcmp(tptr, tm); + if (d == 0) return guess; + if (d < 0) { + guess_hi = guess; + guess -= 24 * 60 * 60; + } + else { + guess_lo = guess; + guess += 24 * 60 * 60; + } + if (guess_lo < guess && guess < guess_hi && + (tm = (utc_p ? gmtime : localtime)(&guess)) != NULL) { + d = tmcmp(tptr, tm); + if (d == 0) return guess; + if (d < 0) + guess_hi = guess; + else + guess_lo = guess; + } } tm = (utc_p ? gmtime : localtime)(&guess_lo); @@ -550,188 +548,190 @@ search_time_t(tptr, utc_p) have_guess = 0; while (guess_lo + 1 < guess_hi) { - /* there is a gap between guess_lo and guess_hi. */ - unsigned long range = 0; - if (!have_guess) { - int a, b; - /* - Try precious guess by a linear interpolation at first. - `a' and `b' is a coefficient of guess_lo and guess_hi as: - - guess = (guess_lo * a + guess_hi * b) / (a + b) - - However this causes overflow in most cases, following assignment - is used instead: - - guess = guess_lo / d * a + (guess_lo % d) * a / d - + guess_hi / d * b + (guess_hi % d) * b / d - where d = a + b - - To avoid overflow in this assignment, `d' is restricted to less than - sqrt(2**31). By this restriction and other reasons, the guess is - not accurate and some error is expected. `range' approximates - the maximum error. - - When these parameters are not suitable, i.e. guess is not within - guess_lo and guess_hi, simple guess by binary search is used. - */ - range = 366 * 24 * 60 * 60; - a = (tm_hi.tm_year - tptr->tm_year); - b = (tptr->tm_year - tm_lo.tm_year); - /* 46000 is selected as `some big number less than sqrt(2**31)'. */ - if (a + b <= 46000 / 12) { - range = 31 * 24 * 60 * 60; - a *= 12; - b *= 12; - a += tm_hi.tm_mon - tptr->tm_mon; - b += tptr->tm_mon - tm_lo.tm_mon; - if (a + b <= 46000 / 31) { - range = 24 * 60 * 60; - a *= 31; - b *= 31; - a += tm_hi.tm_mday - tptr->tm_mday; - b += tptr->tm_mday - tm_lo.tm_mday; - if (a + b <= 46000 / 24) { - range = 60 * 60; - a *= 24; - b *= 24; - a += tm_hi.tm_hour - tptr->tm_hour; - b += tptr->tm_hour - tm_lo.tm_hour; - if (a + b <= 46000 / 60) { - range = 60; - a *= 60; - b *= 60; - a += tm_hi.tm_min - tptr->tm_min; - b += tptr->tm_min - tm_lo.tm_min; - if (a + b <= 46000 / 60) { - range = 1; - a *= 60; - b *= 60; - a += tm_hi.tm_sec - tptr->tm_sec; - b += tptr->tm_sec - tm_lo.tm_sec; + /* there is a gap between guess_lo and guess_hi. */ + unsigned long range = 0; + if (!have_guess) { + int a, b; + /* + Try precious guess by a linear interpolation at first. + `a' and `b' is a coefficient of guess_lo and guess_hi as: + + guess = (guess_lo * a + guess_hi * b) / (a + b) + + However this causes overflow in most cases, following assignment + is used instead: + + guess = guess_lo / d * a + (guess_lo % d) * a / d + + guess_hi / d * b + (guess_hi % d) * b / d + where d = a + b + + To avoid overflow in this assignment, `d' is restricted to less than + sqrt(2**31). By this restriction and other reasons, the guess is + not accurate and some error is expected. `range' approximates + the maximum error. + + When these parameters are not suitable, i.e. guess is not within + guess_lo and guess_hi, simple guess by binary search is used. + */ + range = 366 * 24 * 60 * 60; + a = (tm_hi.tm_year - tptr->tm_year); + b = (tptr->tm_year - tm_lo.tm_year); + /* 46000 is selected as `some big number less than sqrt(2**31)'. */ + if (a + b <= 46000 / 12) { + range = 31 * 24 * 60 * 60; + a *= 12; + b *= 12; + a += tm_hi.tm_mon - tptr->tm_mon; + b += tptr->tm_mon - tm_lo.tm_mon; + if (a + b <= 46000 / 31) { + range = 24 * 60 * 60; + a *= 31; + b *= 31; + a += tm_hi.tm_mday - tptr->tm_mday; + b += tptr->tm_mday - tm_lo.tm_mday; + if (a + b <= 46000 / 24) { + range = 60 * 60; + a *= 24; + b *= 24; + a += tm_hi.tm_hour - tptr->tm_hour; + b += tptr->tm_hour - tm_lo.tm_hour; + if (a + b <= 46000 / 60) { + range = 60; + a *= 60; + b *= 60; + a += tm_hi.tm_min - tptr->tm_min; + b += tptr->tm_min - tm_lo.tm_min; + if (a + b <= 46000 / 60) { + range = 1; + a *= 60; + b *= 60; + a += tm_hi.tm_sec - tptr->tm_sec; + b += tptr->tm_sec - tm_lo.tm_sec; + } + } + } } - } } - } - } - if (a <= 0) a = 1; - if (b <= 0) b = 1; - d = a + b; - /* - Although `/' and `%' may produce unexpected result with negative - argument, it doesn't cause serious problem because there is a - fail safe. - */ - guess = guess_lo / d * a + (guess_lo % d) * a / d - + guess_hi / d * b + (guess_hi % d) * b / d; - have_guess = 1; - } - - if (guess <= guess_lo || guess_hi <= guess) { - /* Precious guess is invalid. try binary search. */ - guess = guess_lo / 2 + guess_hi / 2; - if (guess <= guess_lo) - guess = guess_lo + 1; - else if (guess >= guess_hi) - guess = guess_hi - 1; - range = 0; - } - - tm = (utc_p ? gmtime : localtime)(&guess); - if (!tm) goto error; - have_guess = 0; - - d = tmcmp(tptr, tm); - if (d < 0) { - guess_hi = guess; - tm_hi = *tm; - if (range) { - guess = guess - range; - range = 0; - if (guess_lo < guess && guess < guess_hi) + if (a <= 0) a = 1; + if (b <= 0) b = 1; + d = a + b; + /* + Although `/' and `%' may produce unexpected result with negative + argument, it doesn't cause serious problem because there is a + fail safe. + */ + guess = guess_lo / d * a + (guess_lo % d) * a / d + + guess_hi / d * b + (guess_hi % d) * b / d; have_guess = 1; } - } - else if (d > 0) { - guess_lo = guess; - tm_lo = *tm; - if (range) { - guess = guess + range; - range = 0; - if (guess_lo < guess && guess < guess_hi) - have_guess = 1; + + if (guess <= guess_lo || guess_hi <= guess) { + /* Precious guess is invalid. try binary search. */ + guess = guess_lo / 2 + guess_hi / 2; + if (guess <= guess_lo) + guess = guess_lo + 1; + else if (guess >= guess_hi) + guess = guess_hi - 1; + range = 0; } - } - else { - if (!utc_p) { - /* If localtime is nonmonotonic, another result may exist. */ - time_t guess2; - if (find_dst) { - guess2 = guess - 2 * 60 * 60; - tm = localtime(&guess2); - if (tm) { - if (tptr->tm_hour != (tm->tm_hour + 2) % 24 || - tptr->tm_min != tm->tm_min || - tptr->tm_sec != tm->tm_sec) { - guess2 -= (tm->tm_hour - tptr->tm_hour) * 60 * 60 + - (tm->tm_min - tptr->tm_min) * 60 + - (tm->tm_sec - tptr->tm_sec); - if (tptr->tm_mday != tm->tm_mday) - guess2 += 24 * 60 * 60; - if (guess != guess2) { - tm = localtime(&guess2); - if (tmcmp(tptr, tm) == 0) { - if (guess < guess2) - return guess; - else - return guess2; - } - } - } + + tm = (utc_p ? gmtime : localtime)(&guess); + if (!tm) goto error; + have_guess = 0; + + d = tmcmp(tptr, tm); + if (d < 0) { + guess_hi = guess; + tm_hi = *tm; + if (range) { + guess = guess - range; + range = 0; + if (guess_lo < guess && guess < guess_hi) + have_guess = 1; + } + } + else if (d > 0) { + guess_lo = guess; + tm_lo = *tm; + if (range) { + guess = guess + range; + range = 0; + if (guess_lo < guess && guess < guess_hi) + have_guess = 1; } - } - else { - guess2 = guess + 2 * 60 * 60; - tm = localtime(&guess2); - if (tm) { - if ((tptr->tm_hour + 2) % 24 != tm->tm_hour || - tptr->tm_min != tm->tm_min || - tptr->tm_sec != tm->tm_sec) { - guess2 -= (tm->tm_hour - tptr->tm_hour) * 60 * 60 + - (tm->tm_min - tptr->tm_min) * 60 + - (tm->tm_sec - tptr->tm_sec); - if (tptr->tm_mday != tm->tm_mday) - guess2 -= 24 * 60 * 60; - if (guess != guess2) { - tm = localtime(&guess2); - if (tmcmp(tptr, tm) == 0) { - if (guess < guess2) - return guess2; - else - return guess; - } + } + else { + if (!utc_p) { + /* If localtime is nonmonotonic, another result may exist. */ + time_t guess2; + if (find_dst) { + guess2 = guess - 2 * 60 * 60; + tm = localtime(&guess2); + if (tm) { + if (tptr->tm_hour != (tm->tm_hour + 2) % 24 || + tptr->tm_min != tm->tm_min || + tptr->tm_sec != tm->tm_sec + ) { + guess2 -= (tm->tm_hour - tptr->tm_hour) * 60 * 60 + + (tm->tm_min - tptr->tm_min) * 60 + + (tm->tm_sec - tptr->tm_sec); + if (tptr->tm_mday != tm->tm_mday) + guess2 += 24 * 60 * 60; + if (guess != guess2) { + tm = localtime(&guess2); + if (tmcmp(tptr, tm) == 0) { + if (guess < guess2) + return guess; + else + return guess2; + } + } + } + } + } + else { + guess2 = guess + 2 * 60 * 60; + tm = localtime(&guess2); + if (tm) { + if ((tptr->tm_hour + 2) % 24 != tm->tm_hour || + tptr->tm_min != tm->tm_min || + tptr->tm_sec != tm->tm_sec + ) { + guess2 -= (tm->tm_hour - tptr->tm_hour) * 60 * 60 + + (tm->tm_min - tptr->tm_min) * 60 + + (tm->tm_sec - tptr->tm_sec); + if (tptr->tm_mday != tm->tm_mday) + guess2 -= 24 * 60 * 60; + if (guess != guess2) { + tm = localtime(&guess2); + if (tmcmp(tptr, tm) == 0) { + if (guess < guess2) + return guess2; + else + return guess; + } + } + } + } } - } } - } + return guess; } - return guess; - } } /* Given argument has no corresponding time_t. Let's outerpolation. */ if (tm_lo.tm_year == tptr->tm_year && tm_lo.tm_mon == tptr->tm_mon) { - return guess_lo + - (tptr->tm_mday - tm_lo.tm_mday) * 24 * 60 * 60 + - (tptr->tm_hour - tm_lo.tm_hour) * 60 * 60 + - (tptr->tm_min - tm_lo.tm_min) * 60 + - (tptr->tm_sec - tm_lo.tm_sec); + return guess_lo + + (tptr->tm_mday - tm_lo.tm_mday) * 24 * 60 * 60 + + (tptr->tm_hour - tm_lo.tm_hour) * 60 * 60 + + (tptr->tm_min - tm_lo.tm_min) * 60 + + (tptr->tm_sec - tm_lo.tm_sec); } else if (tm_hi.tm_year == tptr->tm_year && tm_hi.tm_mon == tptr->tm_mon) { - return guess_hi + - (tptr->tm_mday - tm_hi.tm_mday) * 24 * 60 * 60 + - (tptr->tm_hour - tm_hi.tm_hour) * 60 * 60 + - (tptr->tm_min - tm_hi.tm_min) * 60 + - (tptr->tm_sec - tm_hi.tm_sec); + return guess_hi + + (tptr->tm_mday - tm_hi.tm_mday) * 24 * 60 * 60 + + (tptr->tm_hour - tm_hi.tm_hour) * 60 * 60 + + (tptr->tm_min - tm_hi.tm_min) * 60 + + (tptr->tm_sec - tm_hi.tm_sec); } out_of_range: @@ -753,16 +753,17 @@ make_time_t(tptr, utc_p) if (utc_p) { #if defined(HAVE_TIMEGM) if ((t = timegm(&buf)) != -1) - return t; + return t; #ifdef NEGATIVE_TIME_T - if ((tmp = gmtime(&t)) && - tptr->tm_year == tmp->tm_year && - tptr->tm_mon == tmp->tm_mon && - tptr->tm_mday == tmp->tm_mday && - tptr->tm_hour == tmp->tm_hour && - tptr->tm_min == tmp->tm_min && - tptr->tm_sec == tmp->tm_sec) - return t; + if ((tmp = gmtime(&t)) && + tptr->tm_year == tmp->tm_year && + tptr->tm_mon == tmp->tm_mon && + tptr->tm_mday == tmp->tm_mday && + tptr->tm_hour == tmp->tm_hour && + tptr->tm_min == tmp->tm_min && + tptr->tm_sec == tmp->tm_sec + ) + return t; #endif #endif return search_time_t(&buf, utc_p); @@ -770,15 +771,16 @@ make_time_t(tptr, utc_p) else { #if defined(HAVE_MKTIME) if ((t = mktime(&buf)) != -1) - return t; + return t; #ifdef NEGATIVE_TIME_T - if ((tmp = localtime(&t)) && - tptr->tm_year == tmp->tm_year && - tptr->tm_mon == tmp->tm_mon && - tptr->tm_mday == tmp->tm_mday && - tptr->tm_hour == tmp->tm_hour && - tptr->tm_min == tmp->tm_min && - tptr->tm_sec == tmp->tm_sec) + if ((tmp = localtime(&t)) && + tptr->tm_year == tmp->tm_year && + tptr->tm_mon == tmp->tm_mon && + tptr->tm_mday == tmp->tm_mday && + tptr->tm_hour == tmp->tm_hour && + tptr->tm_min == tmp->tm_min && + tptr->tm_sec == tmp->tm_sec + ) return t; #endif #endif @@ -1280,27 +1282,27 @@ time_add(tobj, offset, sign) VALUE result; if (v < 0) { - v = -v; - sign = -sign; + v = -v; + sign = -sign; } d = modf(v, &f); sec_off = (unsigned_time_t)f; if (f != (double)sec_off) - rb_raise(rb_eRangeError, "time %s %f out of Time range", - sign < 0 ? "-" : "+", v); + rb_raise(rb_eRangeError, "time %s %f out of Time range", + sign < 0 ? "-" : "+", v); usec_off = (time_t)(d*1e6); if (sign < 0) { - sec = tobj->tv.tv_sec - sec_off; - usec = tobj->tv.tv_usec - usec_off; - if (sec > tobj->tv.tv_sec) - rb_raise(rb_eRangeError, "time - %f out of Time range", v); + sec = tobj->tv.tv_sec - sec_off; + usec = tobj->tv.tv_usec - usec_off; + if (sec > tobj->tv.tv_sec) + rb_raise(rb_eRangeError, "time - %f out of Time range", v); } else { - sec = tobj->tv.tv_sec + sec_off; - usec = tobj->tv.tv_usec + usec_off; - if (sec < tobj->tv.tv_sec) - rb_raise(rb_eRangeError, "time + %f out of Time range", v); + sec = tobj->tv.tv_sec + sec_off; + usec = tobj->tv.tv_usec + usec_off; + if (sec < tobj->tv.tv_sec) + rb_raise(rb_eRangeError, "time + %f out of Time range", v); } result = rb_time_new(sec, usec); if (tobj->gmt) { @@ -1358,7 +1360,7 @@ time_minus(time1, time2) GetTimeval(time1, tobj); if (TYPE(time2) == T_DATA && RDATA(time2)->dfree == time_free) { struct time_object *tobj2; - double f; + double f; GetTimeval(time2, tobj2); f = (double)tobj->tv.tv_sec - (double)tobj2->tv.tv_sec; -- cgit v1.2.1