* 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
This commit is contained in:
usa 2008-03-06 06:44:41 +00:00
Родитель 774aebb3ce
Коммит ed6b1829ba
2 изменённых файлов: 2 добавлений и 3 удалений

Просмотреть файл

@ -1,4 +1,4 @@
Thu Mar 6 15:16:55 2008 NAKAMURA Usaku <usa@ruby-lang.org> Thu Mar 6 15:44:20 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* sprintf.c (rb_str_format): casting double to long is undefined * sprintf.c (rb_str_format): casting double to long is undefined
if the interger part of double is out of the range of long. if the interger part of double is out of the range of long.

Просмотреть файл

@ -540,8 +540,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
bin_retry: bin_retry:
switch (TYPE(val)) { switch (TYPE(val)) {
case T_FLOAT: case T_FLOAT:
if (RFLOAT_VALUE(val) <= LONG_MAX && if (FIXABLE(RFLOAT_VALUE(val))) {
RFLOAT_VALUE(val) >= LONG_MIN) {
val = LONG2FIX((long)RFLOAT_VALUE(val)); val = LONG2FIX((long)RFLOAT_VALUE(val));
goto bin_retry; goto bin_retry;
} }