ruby-changes:54663
From: nagachika <ko1@a...>
Date: Sun, 20 Jan 2019 14:13:33 +0900 (JST)
Subject: [ruby-changes:54663] nagachika:r66879 (ruby_2_5): merge revision(s) 63322: [Backport #14731]
nagachika 2019-01-20 14:13:27 +0900 (Sun, 20 Jan 2019) New Revision: 66879 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66879 Log: merge revision(s) 63322: [Backport #14731] object.c: fix exponent with underscore * object.c (rb_cstr_to_dbl_raise): do not ignore exponent part when the input string longer than internal buffer contains underscore(s). [ruby-core:86836] [Bug #14731] Modified directories: branches/ruby_2_5/ Modified files: branches/ruby_2_5/object.c branches/ruby_2_5/test/ruby/test_float.rb branches/ruby_2_5/version.h Index: ruby_2_5/object.c =================================================================== --- ruby_2_5/object.c (revision 66878) +++ ruby_2_5/object.c (revision 66879) @@ -3241,7 +3241,8 @@ rb_cstr_to_dbl(const char *p, int badche https://github.com/ruby/ruby/blob/trunk/ruby_2_5/object.c#L3241 if (*end) { char buf[DBL_DIG * 4 + 10]; char *n = buf; - char *e = buf + sizeof(buf) - 1; + char *const init_e = buf + DBL_DIG * 4; + char *e = init_e; char prev = 0; while (p < end && n < e) prev = *n++ = *p++; @@ -3254,6 +3255,9 @@ rb_cstr_to_dbl(const char *p, int badche https://github.com/ruby/ruby/blob/trunk/ruby_2_5/object.c#L3255 } } prev = *p++; + if (e == init_e && (*p == 'e' || *p == 'E')) { + e = buf + sizeof(buf) - 1; + } if (n < e) *n++ = prev; } *n = '\0'; Index: ruby_2_5/version.h =================================================================== --- ruby_2_5/version.h (revision 66878) +++ ruby_2_5/version.h (revision 66879) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1 #define RUBY_VERSION "2.5.4" #define RUBY_RELEASE_DATE "2019-01-20" -#define RUBY_PATCHLEVEL 134 +#define RUBY_PATCHLEVEL 135 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 1 Index: ruby_2_5/test/ruby/test_float.rb =================================================================== --- ruby_2_5/test/ruby/test_float.rb (revision 66878) +++ ruby_2_5/test/ruby/test_float.rb (revision 66879) @@ -163,6 +163,8 @@ class TestFloat < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/ruby/test_float.rb#L163 assert_equal(-31.0*2**-1027, Float("-0x1f"+("0"*268)+".0p-2099")) assert_equal(-31.0*2**-1027, Float("-0x1f"+("0"*600)+".0p-3427")) end + + assert_equal(1.0e10, Float("1.0_"+"00000"*Float::DIG+"e10")) end def test_divmod Index: ruby_2_5 =================================================================== --- ruby_2_5 (revision 66878) +++ ruby_2_5 (revision 66879) Property changes on: ruby_2_5 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r63322 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/