ruby-changes:53905
From: mrkn <ko1@a...>
Date: Sun, 2 Dec 2018 14:22:01 +0900 (JST)
Subject: [ruby-changes:53905] mrkn:r66124 (trunk): Import bigdecimal-1.4.0.pre-20181130a
mrkn 2018-12-02 14:21:54 +0900 (Sun, 02 Dec 2018) New Revision: 66124 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66124 Log: Import bigdecimal-1.4.0.pre-20181130a * https://github.com/ruby/bigdecimal/compare/74d25ef..v1.4.0.pre.20181130a Added directories: trunk/ext/bigdecimal/util/ Added files: trunk/ext/bigdecimal/bigdecimal.def trunk/ext/bigdecimal/util/extconf.rb trunk/ext/bigdecimal/util/util.c Modified files: trunk/ext/bigdecimal/bigdecimal.c trunk/ext/bigdecimal/bigdecimal.gemspec trunk/ext/bigdecimal/bigdecimal.h trunk/ext/bigdecimal/extconf.rb trunk/ext/bigdecimal/lib/bigdecimal/jacobian.rb trunk/ext/bigdecimal/lib/bigdecimal/util.rb trunk/ext/bigdecimal/sample/linear.rb trunk/ext/bigdecimal/sample/nlsolve.rb trunk/test/bigdecimal/test_bigdecimal.rb trunk/test/bigdecimal/test_bigdecimal_util.rb Index: test/bigdecimal/test_bigdecimal_util.rb =================================================================== --- test/bigdecimal/test_bigdecimal_util.rb (revision 66123) +++ test/bigdecimal/test_bigdecimal_util.rb (revision 66124) @@ -12,6 +12,8 @@ class TestBigDecimalUtil < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal_util.rb#L12 def test_Integer_to_d assert_equal(BigDecimal(1), 1.to_d) assert_equal(BigDecimal(2<<100), (2<<100).to_d) + + assert(1.to_d.frozen?) end def test_Float_to_d_without_precision @@ -22,6 +24,11 @@ class TestBigDecimalUtil < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal_util.rb#L24 bug9214 = '[ruby-core:58858]' assert_equal((-0.0).to_d.sign, -1, bug9214) + + assert_raise(TypeError) { 0.3.to_d(nil) } + assert_raise(TypeError) { 0.3.to_d(false) } + + assert(1.1.to_d.frozen?) end def test_Float_to_d_with_precision @@ -32,6 +39,8 @@ class TestBigDecimalUtil < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal_util.rb#L39 bug9214 = '[ruby-core:58858]' assert_equal((-0.0).to_d(digits).sign, -1, bug9214) + + assert(1.1.to_d(digits).frozen?) end def test_Rational_to_d @@ -39,6 +48,8 @@ class TestBigDecimalUtil < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal_util.rb#L48 delta = 1.0/10**(digits) assert_in_delta(BigDecimal(1.quo(2), digits), 1.quo(2).to_d(digits), delta) assert_in_delta(BigDecimal(355.quo(113), digits), 355.quo(113).to_d(digits), delta) + + assert(355.quo(113).to_d(digits).frozen?) end def test_Rational_to_d_with_zero_precision @@ -50,11 +61,30 @@ class TestBigDecimalUtil < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal_util.rb#L61 end def test_String_to_d - assert_equal("2.5".to_d, BigDecimal('2.5')) + assert_equal(BigDecimal('1'), "1__1_1".to_d) + assert_equal(BigDecimal('2.5'), "2.5".to_d) + assert_equal(BigDecimal('2.5'), "2.5 degrees".to_d) + assert_equal(BigDecimal('2.5e1'), "2.5e1 degrees".to_d) + assert_equal(BigDecimal('0'), "degrees 100.0".to_d) + assert_equal(BigDecimal('0.125'), "0.1_2_5".to_d) + assert_equal(BigDecimal('0.125'), "0.1_2_5__".to_d) + assert_equal(BigDecimal('1'), "1_.125".to_d) + assert_equal(BigDecimal('1'), "1._125".to_d) + assert_equal(BigDecimal('0.1'), "0.1__2_5".to_d) + assert_equal(BigDecimal('0.1'), "0.1_e10".to_d) + assert_equal(BigDecimal('0.1'), "0.1e_10".to_d) + assert_equal(BigDecimal('1'), "0.1e1__0".to_d) + + assert("2.5".to_d.frozen?) end def test_invalid_String_to_d assert_equal("invalid".to_d, BigDecimal('0.0')) end + def test_Nil_to_d + assert_equal(nil.to_d, BigDecimal('0.0')) + + assert(nil.to_d) + end end Index: test/bigdecimal/test_bigdecimal.rb =================================================================== --- test/bigdecimal/test_bigdecimal.rb (revision 66123) +++ test/bigdecimal/test_bigdecimal.rb (revision 66124) @@ -44,49 +44,71 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L44 end def test_not_equal - assert_not_equal BigDecimal("1"), BigDecimal.allocate + assert_not_equal BigDecimal("1"), BigDecimal("2") end - def test_global_new + def test_BigDecimal assert_equal(1, BigDecimal("1")) assert_equal(1, BigDecimal("1", 1)) + assert_equal(1, BigDecimal(" 1 ")) + assert_equal(111, BigDecimal("1_1_1_")) + assert_equal(10**(-1), BigDecimal("1E-1"), '#4825') + assert_equal(1234, BigDecimal(" \t\n\r \r1234 \t\n\r \r")) + assert_raise(ArgumentError) { BigDecimal("1", -1) } + assert_raise(ArgumentError, /"1__1_1"/) { BigDecimal("1__1_1") } + assert_raise(ArgumentError, /"_1_1_1"/) { BigDecimal("_1_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("Infinity")) + assert_positive_infinite(BigDecimal("1E1111111111111111111")) assert_positive_infinite(BigDecimal(" \t\n\r \rInfinity \t\n\r \r")) + assert_negative_infinite(BigDecimal("-Infinity")) assert_negative_infinite(BigDecimal(" \t\n\r \r-Infinity \t\n\r \r")) + assert_nan(BigDecimal("NaN")) assert_nan(BigDecimal(" \t\n\r \rNaN \t\n\r \r")) end end - def test_global_new_with_invalid_string + def test_BigDecimal_with_invalid_string [ '', '.', 'e1', 'd1', '.e', '.d', '1.e', '1.d', '.1e', '.1d', - 'invlaid value' + '2,30', '19,000.0', '-2,30', '-19,000.0', '+2,30', '+19,000.0', + '2.3,0', '19.000,0', '-2.3,0', '-19.000,0', '+2.3,0', '+19.000,0', + '2.3.0', '19.000.0', '-2.3.0', '-19.000.0', '+2.3.0', '+19.000.0', + 'invlaid value', '123 xyz' ].each do |invalid_string| assert_raise_with_message(ArgumentError, %Q[invalid value for BigDecimal(): "#{invalid_string}"]) do BigDecimal(invalid_string) end end + + BigDecimal.save_exception_mode do + BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false) + BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false) + assert_raise(ArgumentError, /"Infinity_"/) { BigDecimal("Infinity_") } + assert_raise(ArgumentError, /"+Infinity_"/) { BigDecimal("+Infinity_") } + assert_raise(ArgumentError, /"-Infinity_"/) { BigDecimal("-Infinity_") } + assert_raise(ArgumentError, /"NaN_"/) { BigDecimal("NaN_") } + end end - def test_global_new_with_integer + def test_BigDecimal_with_integer assert_equal(BigDecimal("1"), BigDecimal(1)) assert_equal(BigDecimal("-1"), BigDecimal(-1)) assert_equal(BigDecimal((2**100).to_s), BigDecimal(2**100)) assert_equal(BigDecimal((-2**100).to_s), BigDecimal(-2**100)) end - def test_global_new_with_rational + def test_BigDecimal_with_rational assert_equal(BigDecimal("0.333333333333333333333"), BigDecimal(1.quo(3), 21)) assert_equal(BigDecimal("-0.333333333333333333333"), BigDecimal(-1.quo(3), 21)) assert_raise_with_message(ArgumentError, "can't omit precision for a Rational.") { BigDecimal(42.quo(7)) } end - def test_global_new_with_float + def test_BigDecimal_with_float assert_equal(BigDecimal("0.1235"), BigDecimal(0.1234567, 4)) assert_equal(BigDecimal("-0.1235"), BigDecimal(-0.1234567, 4)) assert_raise_with_message(ArgumentError, "can't omit precision for a Float.") { BigDecimal(4.2) } @@ -107,7 +129,7 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L129 end end - def test_global_new_with_big_decimal + def test_BigDecimal_with_big_decimal assert_equal(BigDecimal(1), BigDecimal(BigDecimal(1))) assert_equal(BigDecimal('+0'), BigDecimal(BigDecimal('+0'))) assert_equal(BigDecimal('-0'), BigDecimal(BigDecimal('-0'))) @@ -120,7 +142,7 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L142 end end - def test_global_new_with_tainted_string + def test_BigDecimal_with_tainted_string Thread.new { $SAFE = 1 BigDecimal('1'.taint) @@ -130,75 +152,15 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L152 end def test_s_ver - assert_warning(/BigDecimal\.ver is deprecated; use BigDecimal::VERSION instead/) do - BigDecimal.ver - end - end - - def test_s_new - assert_warning(/BigDecimal.new is deprecated/) do - BigDecimal.new("1") - end - end - - def test_new - assert_equal(1, BigDecimal("1")) - assert_equal(1, BigDecimal("1", 1)) - assert_equal(1, BigDecimal(" 1 ")) - assert_equal(111, BigDecimal("1_1_1_")) - assert_equal(10**(-1), BigDecimal("1E-1"), '#4825') - - assert_raise(ArgumentError, /"_1_1_1"/) { BigDecimal("_1_1_1") } - - BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false) - BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false) - assert_positive_infinite(BigDecimal("Infinity")) - assert_negative_infinite(BigDecimal("-Infinity")) - assert_nan(BigDecimal("NaN")) - assert_positive_infinite(BigDecimal("1E1111111111111111111")) - end - - def test_new_with_integer - assert_equal(BigDecimal("1"), BigDecimal(1)) - assert_equal(BigDecimal("-1"), BigDecimal(-1)) - assert_equal(BigDecimal((2**100).to_s), BigDecimal(2**100)) - assert_equal(BigDecimal((-2**100).to_s), BigDecimal(-2**100)) - end - - def test_new_with_rational - assert_equal(BigDecimal("0.333333333333333333333"), BigDecimal(1.quo(3), 21)) - assert_equal(BigDecimal("-0.333333333333333333333"), BigDecimal(-1.quo(3), 21)) - assert_raise(ArgumentError) { BigDecimal(1.quo(3)) } - end - - def test_new_with_float - assert_equal(BigDecimal("0.1235"), BigDecimal(0.1234567, 4)) - assert_equal(BigDecimal("-0.1235"), BigDecimal(-0.1234567, 4)) - assert_raise(ArgumentError) { BigDecimal(0.1) } - assert_raise(ArgumentError) { BigDecimal(0.1, Float::DIG + 2) } - assert_nothing_raised { BigDecimal(0.1, Float::DIG + 1) } + assert_raise(NoMethodError, /undefined method `ver`/) { BigDecimal.ver } end - def test_new_with_big_decimal - assert_equal(BigDecimal(1), BigDecimal(BigDecimal(1))) - assert_equal(BigDecimal('+0'), BigDecimal(BigDecimal('+0'))) - assert_equal(BigDecimal('-0'), BigDecimal(BigDecimal('-0'))) - BigDecimal.save_exception_mode do - BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false) - BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false) - assert_positive_infinite(BigDecimal(BigDecimal('Infinity'))) - assert_negative_infinite(BigDecimal(BigDecimal('-Infinity'))) - assert_nan(BigDecimal(BigDecimal('NaN'))) - end + def test_s_allocate + assert_raise(NoMethodError, /undefined method `allocate`/) { BigDecimal.allocate } end - def test_new_with_tainted_string - Thread.new { - $SAFE = 1 - BigDecimal('1'.taint) - }.join - ensure - $SAFE = 0 + def test_s_new + assert_raise(NoMethodError, /undefined method `new`/) { BigDecimal.new("1") } end def _test_mode(type) @@ -1778,6 +1740,12 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L1740 EOS end + def test_frozen_p + x = BigDecimal(1) + assert(x.frozen?) + assert((x + x).frozen?) + end + def test_clone assert_warning(/^$/) do x = BigDecimal(0) @@ -1795,14 +1763,8 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L1763 end def test_dup_subclass - assert_warning(/BigDecimal\.new is deprecated/) do - c = Class.new(BigDecimal) - x = c.new(1) - y = x.dup - assert_same(x, y) - assert_equal(1, y) - assert_kind_of(c, y) - end + c = Class.new(BigDecimal) + assert_raise(NoMethodError, /undefined method `new`/) { c.new(1) } end def test_to_d @@ -1834,7 +1796,7 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L1796 assert_no_memory_leak("BigDecimal()") end - def test_no_memory_leak_global_new + def test_no_memory_leak_BigDecimal assert_no_memory_leak("BigDecimal('10')") assert_no_memory_leak("BigDecimal(b)") end Index: ext/bigdecimal/bigdecimal.h =================================================================== --- ext/bigdecimal/bigdecimal.h (revision 66123) +++ ext/bigdecimal/bigdecimal.h (revision 66124) @@ -308,7 +308,7 @@ VP_EXPORT size_t VpInit(BDIGIT BaseVal); https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.h#L308 VP_EXPORT void *VpMemAlloc(size_t mb); VP_EXPORT void *VpMemRealloc(void *ptr, size_t mb); VP_EXPORT void VpFree(Real *pv); -VP_EXPORT Real *VpAlloc(size_t mx, const char *szVal); +VP_EXPORT Real *VpAlloc(size_t mx, const char *szVal, int strict_p); VP_EXPORT size_t VpAsgn(Real *c, Real *a, int isw); VP_EXPORT size_t VpAddSub(Real *c,Real *a,Real *b,int operation); VP_EXPORT size_t VpMult(Real *c,Real *a,Real *b); Index: ext/bigdecimal/lib/bigdecimal/jacobian.rb =================================================================== --- ext/bigdecimal/lib/bigdecimal/jacobian.rb (revision 66123) +++ ext/bigdecimal/lib/bigdecimal/jacobian.rb (revision 66124) @@ -21,6 +21,9 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal/jacobian.rb#L21 # # fx is f.values(x). # + +require 'bigdecimal' + module Jacobian module_function Index: ext/bigdecimal/lib/bigdecimal/util.rb =================================================================== --- ext/bigdecimal/lib/bigdecimal/util.rb (revision 66123) +++ ext/bigdecimal/lib/bigdecimal/util.rb (revision 66124) @@ -5,6 +5,8 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal/util.rb#L5 # and provides BigDecimal#to_d and BigDecimal#to_digits. #++ +require 'bigdecimal' +require 'bigdecimal/util.so' class Integer < Numeric # call-seq: @@ -42,8 +44,8 @@ class Float < Numeric https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal/util.rb#L44 # # See also BigDecimal::new. # - def to_d(precision=nil) - BigDecimal(self, precision || Float::DIG) + def to_d(precision=Float::DIG) + BigDecimal(self, precision) end end @@ -64,13 +66,6 @@ class String https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal/util.rb#L66 # # See also BigDecimal::new. # - def to_d - begin - BigDecimal(self) - rescue ArgumentError - BigDecimal(0) - end - end end @@ -132,3 +127,20 @@ class Rational < Numeric https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal/util.rb#L127 BigDecimal(self, precision) end end + + +class NilClass + # call-seq: + # nil.to_d -> bigdecimal + # + # Returns nil represented as a BigDecimal. + # + # require 'bigdecimal' + # require 'bigdecimal/util' + # + # nil.to_d # => 0.0 + # + def to_d + BigDecimal(0) + end +end Index: ext/bigdecimal/extconf.rb =================================================================== --- ext/bigdecimal/extconf.rb (revision 66123) +++ ext/bigdecimal/extconf.rb (revision 66124) @@ -1,6 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/extconf.rb#L1 # frozen_string_literal: false require 'mkmf' +def windows_platform? + /cygwin|mingw|mswin/ === RUBY_PLATFORM +end + gemspec_name = gemspec_path = nil unless ['', '../../'].any? {|dir| gemspec_name = "#{dir}bigdecimal.gemspec" @@ -17,8 +21,6 @@ bigdecimal_version = https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/extconf.rb#L21 $defs << %Q[-DRUBY_BIGDECIMAL_VERSION=\\"#{bigdecimal_version}\\"] -alias __have_macro__ have_macro - have_func("labs", "stdlib.h") have_func("llabs", "stdlib.h") have_func("finite", "math.h") @@ -30,6 +32,38 @@ have_func("rb_rational_den", "ruby.h") https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/extconf.rb#L32 have_func("rb_array_const_ptr", "ruby.h") have_func("rb_sym2str", "ruby.h") +if windows_platform? + library_base_name = "ruby-bigdecimal" + case RUBY_PLATFORM + when /cygwin|mingw/ + import_library_name = "libruby-bigdecimal.a" + when /mswin/ + import_library_name = "bigdecimal-$(arch).lib" + end +end + +checking_for(checking_message("Windows")) do + if windows_platform? + case RUBY_PLATFORM + when /cygwin|mingw/ + $DLDFLAGS << " $(srcdir)/bigdecimal.def" + $DLDFLAGS << " -Wl,--out-implib=$(TARGET_SO_DIR)#{import_library_name}" + when /mswin/ + $DLDFLAGS << " /DEF:$(srcdir)/bigdecimal.def" + end + $cleanfiles << import_library_name + true + else + false + end +end + create_makefile('bigdecimal') {|mf| mf << "\nall:\n\nextconf.h: $(srcdir)/#{gemspec_name}\n" + case RUBY_PLATFORM + when /mswin/ + mf << "\nall:\n\tdir $(TARGET_SO_DIR)" + else + mf << "\nall:\n\tls $(TARGET_SO_DIR)" + end } Index: ext/bigdecimal/bigdecimal.def =================================================================== --- ext/bigdecimal/bigdecimal.def (nonexistent) +++ ext/bigdecimal/bigdecimal.def (revision 66124) @@ -0,0 +1,3 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.def#L1 +EXPORTS +rmpd_util_str_to_d +Init_bigdecimal Index: ext/bigdecimal/util/extconf.rb =================================================================== --- ext/bigdecimal/util/extconf.rb (nonexistent) +++ ext/bigdecimal/util/extconf.rb (revision 66124) @@ -0,0 +1,40 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/util/extconf.rb#L1 +# frozen_string_literal: false +require 'mkmf' + +def windows_platform? + /cygwin|mingw|mswin/ === RUBY_PLATFORM +end + +if windows_platform? + library_base_name = "ruby-bigdecimal" + case RUBY_PLATFORM + when /cygwin|mingw/ + import_library_name = "libruby-bigdecimal.a" + when /mswin/ + import_library_name = "bigdecimal-$(arch).lib" + end +end + +checking_for(checking_message("Windows")) do + if windows_platform? + if defined?($extlist) + build_dir = "$(TARGET_SO_DIR)../" + else + base_dir = File.expand_path('../../../..', __FILE__) + build_dir = File.join(base_dir, "tmp", RUBY_PLATFORM, "bigdecimal", RUBY_VERSION) + end + case RUBY_PLATFORM + when /cygwin|mingw/ + $LDFLAGS << " -L#{build_dir} -L.. -L .." + $libs << " -l#{library_base_name}" + when /mswin/ + $DLDFLAGS << " /libpath:#{build_dir} /libpath:.." + $libs << " #{import_library_name}" + end + true + else + false + end +end + +create_makefile('bigdecimal/util') Index: ext/bigdecimal/util/util.c =================================================================== --- ext/bigdecimal/util/util.c (nonexistent) +++ ext/bigdecimal/util/util.c (revision 66124) @@ -0,0 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/util/util.c#L1 +#include "ruby.h" + +RUBY_EXTERN VALUE rmpd_util_str_to_d(VALUE str); + +void +Init_util(void) +{ + rb_define_method(rb_cString, "to_d", rmpd_util_str_to_d, 0); +} Index: ext/bigdecimal/bigdecimal.c =================================================================== --- ext/bigdecimal/bigdecimal.c (revision 66123) +++ ext/bigdecimal/bigdecimal.c (revision 66124) @@ -136,24 +136,6 @@ rb_rational_den(VALUE rat) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L136 #define DoSomeOne(x,y,f) rb_num_coerce_bin(x,y,f) /* - * Returns the BigDecimal version number. - */ -static VALUE -BigDecimal_version(VALUE self) -{ - /* - * 1.0.0: Ruby 1.8.0 - * 1.0.1: Ruby 1.8.1 - * 1.1.0: Ruby 1.9.3 - */ -#ifndef RUBY_BIGDECIMAL_VERSION -# error RUBY_BIGDECIMAL_VERSION is not defined -#endif - rb_warning("BigDecimal.ver is deprecated; use BigDecimal::VERSION instead."); - return rb_str_new2(RUBY_BIGDECIMAL_VERSION); -} - -/* * VP routines used in BigDecimal part */ static unsigned short VpGetException(void); @@ -664,9 +646,10 @@ VP_EXPORT Real * https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L646 VpNewRbClass(size_t mx, const char *str, VALUE klass) { VALUE obj = TypedData_Wrap_Struct(klass, &BigDecimal_data_type, 0); - Real *pv = VpAlloc(mx,str); + Real *pv = VpAlloc(mx, str, 1); RTYPEDDATA_DATA(obj) = pv; pv->obj = obj; + RB_OBJ_FREEZE(obj); return pv; } @@ -2165,15 +2148,10 @@ BigDecimal_exponent(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2148 return INT2NUM(e); } -/* Returns debugging information about the value as a string of comma-separated - * (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/