ruby-changes:7927
From: tadf <ko1@a...>
Date: Sun, 21 Sep 2008 21:53:58 +0900 (JST)
Subject: [ruby-changes:7927] Ruby:r19448 (trunk): * math.c (math_log): should check argc.
tadf 2008-09-21 21:53:40 +0900 (Sun, 21 Sep 2008) New Revision: 19448 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19448 Log: * math.c (math_log): should check argc. Modified files: trunk/ChangeLog trunk/math.c trunk/test/ruby/test_math.rb Index: math.c =================================================================== --- math.c (revision 19447) +++ math.c (revision 19448) @@ -353,7 +353,7 @@ Need_Float(x); errno = 0; d = log(RFLOAT_VALUE(x)); - if (!NIL_P(base)) { + if (argc == 2) { Need_Float(base); d /= log(RFLOAT_VALUE(base)); } Index: ChangeLog =================================================================== --- ChangeLog (revision 19447) +++ ChangeLog (revision 19448) @@ -1,3 +1,7 @@ +Sun Sep 21 21:52:41 2008 Tadayoshi Funaba <tadf@d...> + + * math.c (math_log): should check argc. + Sun Sep 21 21:20:24 2008 Tadayoshi Funaba <tadf@d...> * complex.c: added two macros. Index: test/ruby/test_math.rb =================================================================== --- test/ruby/test_math.rb (revision 19447) +++ test/ruby/test_math.rb (revision 19448) @@ -113,6 +113,7 @@ assert_equal(1.0/0, Math.log(1.0/0)) assert_raise(Errno::EDOM, Errno::ERANGE) { Math.log(0) } assert_raise(Errno::EDOM, Errno::ERANGE) { Math.log(-1) } + assert_raise(TypeError) { Math.log(1,nil) } end def test_log2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/