ruby-changes:17784
From: yugui <ko1@a...>
Date: Mon, 15 Nov 2010 20:44:05 +0900 (JST)
Subject: [ruby-changes:17784] Ruby:r29795 (ruby_1_9_2): merges r29187 and r29239 from trunk into ruby_1_9_2, but does not raise
yugui 2010-11-15 20:43:50 +0900 (Mon, 15 Nov 2010) New Revision: 29795 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29795 Log: merges r29187 and r29239 from trunk into ruby_1_9_2, but does not raise an error. just warning. -- * util.c (ruby_strtod): reject Float('0x0.'). [ruby-dev:42239] Bug #3820 -- * util.c (ruby_strtod): check there is at least 1 digit after "0x" before ".". [ruby-dev:42183] #3790 Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/test/ruby/envutil.rb branches/ruby_1_9_2/test/ruby/test_float.rb branches/ruby_1_9_2/util.c branches/ruby_1_9_2/version.h Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 29794) +++ ruby_1_9_2/ChangeLog (revision 29795) @@ -1,3 +1,8 @@ +Mon Sep 13 10:12:09 2010 NARUSE, Yui <naruse@r...> + + * util.c (ruby_strtod): reject Float('0x0.'). + [ruby-dev:42239] Bug #3820 + Mon Sep 13 09:23:58 2010 NARUSE, Yui <naruse@r...> * ext/openssl/ossl_bn.c (ossl_bn_is_prime): fix comparison Index: ruby_1_9_2/util.c =================================================================== --- ruby_1_9_2/util.c (revision 29794) +++ ruby_1_9_2/util.c (revision 29795) @@ -2120,7 +2120,11 @@ static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF"; s0 = ++s; adj = 0; + aadj = -1; + if (!s[1]) { + rb_warn("malformed value for Float(): %s. Ruby 1.9.3 for later will raise an ArgumentError for the value.", s00); + } while (*++s && (s1 = strchr(hexdigit, *s))) { adj *= 16; adj += (s1 - hexdigit) & 15; @@ -2151,6 +2155,9 @@ dval(rv) = ldexp(adj, nd * dsign); } else { + if (aadj != -1) { + rb_warn("malformed value for Float(): %s. Ruby 1.9.3 for later will raise an ArgumentError for the value.", s00); + } dval(rv) = adj; } goto ret; Index: ruby_1_9_2/version.h =================================================================== --- ruby_1_9_2/version.h (revision 29794) +++ ruby_1_9_2/version.h (revision 29795) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 39 +#define RUBY_PATCHLEVEL 40 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 Index: ruby_1_9_2/test/ruby/test_float.rb =================================================================== --- ruby_1_9_2/test/ruby/test_float.rb (revision 29794) +++ ruby_1_9_2/test/ruby/test_float.rb (revision 29795) @@ -1,4 +1,5 @@ require 'test/unit' +require_relative 'envutil' class TestFloat < Test::Unit::TestCase def test_float @@ -91,7 +92,6 @@ assert_equal([ 0.0].pack('G'), [Float(" 0x0p+0").to_f].pack('G')) assert_equal([-0.0].pack('G'), [Float("-0x0p+0").to_f].pack('G')) assert_equal(255.0, Float("0Xff")) - assert_equal(255.5, Float("0Xff.8")) assert_equal(1.0, Float("0X1.P+0")) assert_equal(1024.0, Float("0x1p10")) assert_equal(1024.0, Float("0x1p+10")) @@ -430,7 +430,11 @@ assert(!Float(([1] * 10000).join("_")).infinite?) # is it really OK? assert_raise(ArgumentError) { Float("1.0\x001") } assert_equal(15.9375, Float('0xf.fp0')) - assert_raise(ArgumentError) { Float('0xf.fp') } + assert_warn(/malformed value for Float\(\).*?Ruby 1\.9\.3/) { Float('0x') } + assert_equal(15.0, Float('0xf')) + assert_equal(15.0, Float('0xfp0')) + assert_equal(15.0, Float('0xf.p0')) + assert_warn(/malformed value for Float\(\).*?Ruby 1\.9\.3/) { Float('0xf.f') } assert_equal(1, Float("1e10_00").infinite?) assert_raise(TypeError) { Float(nil) } o = Object.new Index: ruby_1_9_2/test/ruby/envutil.rb =================================================================== --- ruby_1_9_2/test/ruby/envutil.rb (revision 29794) +++ ruby_1_9_2/test/ruby/envutil.rb (revision 29795) @@ -208,6 +208,11 @@ assert(status.success?, m) end + def assert_warn(msg) + stderr = EnvUtil.verbose_warning { yield } + assert(msg === stderr, "warning message #{stderr.inspect} is expected to match #{msg.inspect}") + end + end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/