ruby-changes:12259
From: akr <ko1@a...>
Date: Fri, 3 Jul 2009 22:49:56 +0900 (JST)
Subject: [ruby-changes:12259] Ruby:r23949 (trunk): * time.c (find_time_t): less number of guesses for hh:mm:60.
akr 2009-07-03 22:49:41 +0900 (Fri, 03 Jul 2009) New Revision: 23949 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23949 Log: * time.c (find_time_t): less number of guesses for hh:mm:60. Modified files: trunk/ChangeLog trunk/time.c Index: time.c =================================================================== --- time.c (revision 23948) +++ time.c (revision 23949) @@ -1862,10 +1862,12 @@ #if 0 #define DEBUG_FIND_TIME_NUMGUESS -#define DEBUG_REPORT_GUESSRANGE fprintf(stderr, "find time guess range: %ld - %ld : %lu\n", guess_lo, guess_hi, (unsigned_time_t)(guess_hi-guess_lo)) +#define DEBUG_GUESSRANGE #endif -#ifndef DEBUG_REPORT_GUESSRANGE +#ifdef DEBUG_GUESSRANGE +#define DEBUG_REPORT_GUESSRANGE fprintf(stderr, "find time guess range: %ld - %ld : %lu\n", guess_lo, guess_hi, (unsigned_time_t)(guess_hi-guess_lo)) +#else #define DEBUG_REPORT_GUESSRANGE #endif @@ -1962,15 +1964,23 @@ if (status == 1) { time_t guess0_hi = timegm_noleapsecond(&tm_hi); guess = guess_hi - (guess0_hi - guess0); + if (guess == guess_hi) /* hh:mm:60 tends to cause this condition. */ + guess--; status = 2; } else if (status == 2) { time_t guess0_lo = timegm_noleapsecond(&tm_lo); guess = guess_lo + (guess0 - guess0_lo); + if (guess == guess_lo) + guess++; status = 0; } if (guess <= guess_lo || guess_hi <= guess) { /* Precious guess is invalid. try binary search. */ +#ifdef DEBUG_GUESSRANGE + if (guess <= guess_lo) fprintf(stderr, "too small guess: %ld <= %ld\n", guess, guess_lo); + if (guess_hi <= guess) fprintf(stderr, "too big guess: %ld <= %ld\n", guess_hi, guess); +#endif goto binsearch; } } Index: ChangeLog =================================================================== --- ChangeLog (revision 23948) +++ ChangeLog (revision 23949) @@ -1,3 +1,7 @@ +Fri Jul 3 22:48:45 2009 Tanaka Akira <akr@f...> + + * time.c (find_time_t): less number of guesses for hh:mm:60. + Fri Jul 3 21:30:14 2009 Tadayoshi Funaba <tadf@d...> * complex.c (nucomp_equal_p): removed. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/