ruby-changes:44971
From: mrkn <ko1@a...>
Date: Sat, 10 Dec 2016 17:56:09 +0900 (JST)
Subject: [ruby-changes:44971] mrkn:r57044 (trunk): bigdecimal: version 1.3.0.pre.2
mrkn 2016-12-10 17:56:05 +0900 (Sat, 10 Dec 2016) New Revision: 57044 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57044 Log: bigdecimal: version 1.3.0.pre.2 Import bigdecimal version 1.3.0.pre.2. The full commit log is here: https://github.com/ruby/bigdecimal/compare/v1.3.0.pre...v1.3.0.pre.2 Modified files: trunk/ext/bigdecimal/bigdecimal.c trunk/ext/bigdecimal/bigdecimal.gemspec trunk/test/bigdecimal/test_bigdecimal.rb Index: ext/bigdecimal/bigdecimal.c =================================================================== --- ext/bigdecimal/bigdecimal.c (revision 57043) +++ ext/bigdecimal/bigdecimal.c (revision 57044) @@ -4003,26 +4003,6 @@ VpAlloc(size_t mx, const char *szVal) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4003 return vp; } - /* Check on Inf & NaN */ - if (StrCmp(szVal, SZ_PINF) == 0 || StrCmp(szVal, SZ_INF) == 0 ) { - vp = VpAllocReal(1); - vp->MaxPrec = 1; /* set max precision */ - VpSetPosInf(vp); - return vp; - } - if (StrCmp(szVal, SZ_NINF) == 0) { - vp = VpAllocReal(1); - vp->MaxPrec = 1; /* set max precision */ - VpSetNegInf(vp); - return vp; - } - if (StrCmp(szVal, SZ_NaN) == 0) { - vp = VpAllocReal(1); - vp->MaxPrec = 1; /* set max precision */ - VpSetNaN(vp); - return vp; - } - /* Skip all '_' after digit: 2006-6-30 */ ni = 0; buf = rb_str_tmp_new(strlen(szVal) + 1); @@ -4048,6 +4028,26 @@ VpAlloc(size_t mx, const char *szVal) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4028 } szVal = psz; + /* Check on Inf & NaN */ + if (StrCmp(szVal, SZ_PINF) == 0 || StrCmp(szVal, SZ_INF) == 0 ) { + vp = VpAllocReal(1); + vp->MaxPrec = 1; /* set max precision */ + VpSetPosInf(vp); + return vp; + } + if (StrCmp(szVal, SZ_NINF) == 0) { + vp = VpAllocReal(1); + vp->MaxPrec = 1; /* set max precision */ + VpSetNegInf(vp); + return vp; + } + if (StrCmp(szVal, SZ_NaN) == 0) { + vp = VpAllocReal(1); + vp->MaxPrec = 1; /* set max precision */ + VpSetNaN(vp); + return vp; + } + /* check on number szVal[] */ ipn = i = 0; if (szVal[i] == '-') { sign=-1; ++i; } Index: ext/bigdecimal/bigdecimal.gemspec =================================================================== --- ext/bigdecimal/bigdecimal.gemspec (revision 57043) +++ ext/bigdecimal/bigdecimal.gemspec (revision 57044) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.gemspec#L1 # coding: utf-8 -_VERSION = '1.3.0.pre' +_VERSION = '1.3.0.pre.2' Gem::Specification.new do |s| s.name = "bigdecimal" Index: test/bigdecimal/test_bigdecimal.rb =================================================================== --- test/bigdecimal/test_bigdecimal.rb (revision 57043) +++ test/bigdecimal/test_bigdecimal.rb (revision 57044) @@ -53,6 +53,15 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L53 assert_equal(1, BigDecimal("1")) assert_equal(1, BigDecimal("1", 1)) assert_raise(ArgumentError) { BigDecimal("1", -1) } + + BigDecimal.save_exception_mode do + BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false) + BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false) + assert_equal(1234, BigDecimal(" \t\n\r \r1234 \t\n\r \r")) + assert_positive_infinite(BigDecimal(" \t\n\r \rInfinity \t\n\r \r")) + assert_negative_infinite(BigDecimal(" \t\n\r \r-Infinity \t\n\r \r")) + assert_nan(BigDecimal(" \t\n\r \rNaN \t\n\r \r")) + end end def test_global_new_with_invalid_string -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/