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

ruby-changes:46581

From: nobu <ko1@a...>
Date: Sat, 13 May 2017 09:50:28 +0900 (JST)
Subject: [ruby-changes:46581] nobu:r58697 (trunk): math.c: check argument to tgamma

nobu	2017-05-13 09:50:20 +0900 (Sat, 13 May 2017)

  New Revision: 58697

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58697

  Log:
    math.c: check argument to tgamma
    
    * math.c (math_gamma): check the argument before calling math
      function `tgamma` for edge cases.

  Modified files:
    trunk/configure.in
    trunk/math.c
Index: math.c
===================================================================
--- math.c	(revision 58696)
+++ math.c	(revision 58697)
@@ -869,7 +869,13 @@ math_gamma(VALUE unused_obj, VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L869
     double d;
     d = Get_Double(x);
     /* check for domain error */
-    if (isinf(d) && signbit(d)) domain_error("gamma");
+    if (isinf(d)) {
+	if (signbit(d)) domain_error("gamma");
+	return DBL2NUM(INFINITY);
+    }
+    if (d == 0.0) {
+	return signbit(d) ? DBL2NUM(-INFINITY) : DBL2NUM(INFINITY);
+    }
     if (d == floor(d)) {
 	if (d < 0.0) domain_error("gamma");
 	if (1.0 <= d && d <= (double)NFACT_TABLE) {
Index: configure.in
===================================================================
--- configure.in	(revision 58696)
+++ configure.in	(revision 58697)
@@ -1317,7 +1317,6 @@ main() https://github.com/ruby/ruby/blob/trunk/configure.in#L1317
 		    ac_cv_func___builtin_setjmp=no
 		    ac_cv_func_round=no
 		])
-		ac_cv_func_tgamma=no
 		AC_CHECK_TYPE([NET_LUID], [], [],
 			      [@%:@include <winsock2.h>
 			      @%:@include <iphlpapi.h>])

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

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