From ed6b1829bad6c30c00b68d5efdf4c2f1af12cc80 Mon Sep 17 00:00:00 2001 From: usa Date: Thu, 6 Mar 2008 06:44:41 +0000 Subject: [PATCH] * sprintf.c (rb_str_format): casting double to long is undefined if the interger part of double is out of the range of long. (fix previous commit). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 2 +- sprintf.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf507ee2f6..2176d01e1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -Thu Mar 6 15:16:55 2008 NAKAMURA Usaku +Thu Mar 6 15:44:20 2008 NAKAMURA Usaku * sprintf.c (rb_str_format): casting double to long is undefined if the interger part of double is out of the range of long. diff --git a/sprintf.c b/sprintf.c index 795af92373..63ac093f29 100644 --- a/sprintf.c +++ b/sprintf.c @@ -540,8 +540,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) bin_retry: switch (TYPE(val)) { case T_FLOAT: - if (RFLOAT_VALUE(val) <= LONG_MAX && - RFLOAT_VALUE(val) >= LONG_MIN) { + if (FIXABLE(RFLOAT_VALUE(val))) { val = LONG2FIX((long)RFLOAT_VALUE(val)); goto bin_retry; }