[前][次][番号順一覧][スレッド一覧]

ruby-changes:65240

From: Nobuyoshi <ko1@a...>
Date: Thu, 11 Feb 2021 23:54:39 +0900 (JST)
Subject: [ruby-changes:65240] aea40f44aa (master): Fixed time_t conversion modifiers for debug

https://git.ruby-lang.org/ruby.git/commit/?id=aea40f44aa

From aea40f44aa2918f5b64d2eab1720b3d63a8b2c98 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 11 Feb 2021 23:53:29 +0900
Subject: Fixed time_t conversion modifiers for debug

---
 time.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/time.c b/time.c
index d75c832..050a526 100644
--- a/time.c
+++ b/time.c
@@ -3005,10 +3005,17 @@ static const bool debug_guessrange = https://github.com/ruby/ruby/blob/trunk/time.c#L3005
     false;
 #endif
 
-#define DEBUG_REPORT_GUESSRANGE (void)\
-    (debug_guessrange ? \
-     fprintf(stderr, "find time guess range: %ld - %ld : %"PRI_TIMET_PREFIX"u\n", \
-             guess_lo, guess_hi, (unsigned_time_t)(guess_hi-guess_lo)) : 0)
+#define DEBUG_REPORT_GUESSRANGE \
+    (debug_guessrange ? debug_report_guessrange(guess_lo, guess_hi) : (void)0)
+
+static inline void
+debug_report_guessrange(time_t guess_lo, time_t guess_hi)
+{
+    unsigned_time_t guess_diff = (unsigned_time_t)(guess_hi-guess_lo);
+    fprintf(stderr, "find time guess range: %"PRI_TIMET_PREFIX"d - "
+            "%"PRI_TIMET_PREFIX"d : %"PRI_TIMET_PREFIX"u\n",
+            guess_lo, guess_hi, guess_diff);
+}
 
 static const bool debug_find_time_numguess =
 #ifdef DEBUG_FIND_TIME_NUMGUESS
@@ -3175,8 +3182,14 @@ find_time_t(struct tm *tptr, int utc_p, time_t *tp) https://github.com/ruby/ruby/blob/trunk/time.c#L3182
             if (guess <= guess_lo || guess_hi <= guess) {
                 /* Previous guess is invalid. try binary search. */
                 if (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);
+                    if (guess <= guess_lo) {
+                        fprintf(stderr, "too small guess: %"PRI_TIMET_PREFIX"d"\
+                                " <= %"PRI_TIMET_PREFIX"d\n", guess, guess_lo);
+                    }
+                    if (guess_hi <= guess) {
+                        fprintf(stderr, "too big guess: %"PRI_TIMET_PREFIX"d"\
+                                " <= %"PRI_TIMET_PREFIX"d\n", guess_hi, guess);
+                    }
                 }
                 status = 0;
                 goto binsearch;
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]