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

ruby-changes:4223

From: ko1@a...
Date: Thu, 6 Mar 2008 15:21:11 +0900 (JST)
Subject: [ruby-changes:4223] usa - Ruby:r15713 (trunk): * sprintf.c (rb_str_format): casting double to long is undefined

usa	2008-03-06 15:20:48 +0900 (Thu, 06 Mar 2008)

  New Revision: 15713

  Modified files:
    trunk/ChangeLog
    trunk/sprintf.c

  Log:
    * sprintf.c (rb_str_format): casting double to long is undefined
      if the interger part of double is out of the range of long.
    


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15713&r2=15712&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/sprintf.c?r1=15713&r2=15712&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15712)
+++ ChangeLog	(revision 15713)
@@ -1,3 +1,8 @@
+Thu Mar  6 15:16:55 2008  NAKAMURA Usaku  <usa@r...>
+
+	* 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@r...>
 
 	* sprintf.c (rb_str_format): ignore 0 flag for NaN and Inf.
Index: sprintf.c
===================================================================
--- sprintf.c	(revision 15712)
+++ sprintf.c	(revision 15713)
@@ -540,7 +540,8 @@
 	      bin_retry:
 		switch (TYPE(val)) {
 		  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));
 			goto bin_retry;
 		    }

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

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