mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* sprintf.c (rb_str_format): casting double to long is undefined
if the interger part of double is out of the range of long. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
591503c0ab
commit
16d0ad4899
2 changed files with 7 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Mar 6 15:16:55 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
|
* sprintf.c (rb_str_format): casting double to long is undefined
|
||||||
|
if the interger part of double is out of the range of long.
|
||||||
|
|
||||||
Thu Mar 6 15:11:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Mar 6 15:11:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* sprintf.c (rb_str_format): ignore 0 flag for NaN and Inf.
|
* sprintf.c (rb_str_format): ignore 0 flag for NaN and Inf.
|
||||||
|
|
|
@ -540,7 +540,8 @@ 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 (FIXABLE((long)RFLOAT_VALUE(val))) {
|
if (RFLOAT_VALUE(val) <= LONG_MAX &&
|
||||||
|
RFLOAT_VALUE(val) >= LONG_MIN) {
|
||||||
val = LONG2FIX((long)RFLOAT_VALUE(val));
|
val = LONG2FIX((long)RFLOAT_VALUE(val));
|
||||||
goto bin_retry;
|
goto bin_retry;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue