ruby-changes:19725
From: yugui <ko1@a...>
Date: Sun, 29 May 2011 08:31:57 +0900 (JST)
Subject: [ruby-changes:19725] yugui:r31770 (ruby_1_9_2): * strftime.c (STRFTIME): return 0 and ERANGE when precision is too
yugui 2011-05-29 08:31:44 +0900 (Sun, 29 May 2011) New Revision: 31770 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31770 Log: * strftime.c (STRFTIME): return 0 and ERANGE when precision is too large. [ruby-dev:43284] fixes #4456 based on r31011. * test/test_time.rb (TestTime#test_huge_precision): test for #4456. Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/strftime.c branches/ruby_1_9_2/test/test_time.rb branches/ruby_1_9_2/version.h Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 31769) +++ ruby_1_9_2/ChangeLog (revision 31770) @@ -1,3 +1,11 @@ +Sat May 14 12:20:22 2011 Yuki Sonoda (Yugui) <yugui@y...> + + * strftime.c (STRFTIME): return 0 and ERANGE when precision is too + large. [ruby-dev:43284] fixes #4456 + based on r31011. + + * test/test_time.rb (TestTime#test_huge_precision): test for #4456. + Sat Feb 26 07:10:05 2011 Aaron Patterson <aaron@t...> * ext/psych/lib/psych/scalar_scanner.rb: fix parsing timezone's whose Index: ruby_1_9_2/strftime.c =================================================================== --- ruby_1_9_2/strftime.c (revision 31769) +++ ruby_1_9_2/strftime.c (revision 31770) @@ -309,6 +309,7 @@ i = rb_strftime_with_timespec(s, endp - s, fmt, vtm, timev, ts, gmt); \ if (!i) return 0; \ if (precision > i) {\ + NEEDS(precision); \ memmove(s + precision - i, s, i);\ memset(s, padding ? padding : ' ', precision - i); \ s += precision; \ Index: ruby_1_9_2/version.h =================================================================== --- ruby_1_9_2/version.h (revision 31769) +++ ruby_1_9_2/version.h (revision 31770) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 208 +#define RUBY_PATCHLEVEL 209 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 Index: ruby_1_9_2/test/test_time.rb =================================================================== --- ruby_1_9_2/test/test_time.rb (revision 31769) +++ ruby_1_9_2/test/test_time.rb (revision 31770) @@ -1,5 +1,6 @@ require 'time' require 'test/unit' +require_relative 'ruby/envutil.rb' class TestTimeExtension < Test::Unit::TestCase # :nodoc: def test_rfc822 @@ -397,4 +398,9 @@ assert_equal(123456789, Time.xmlschema("2000-01-01T00:00:00.123456789+00:00").tv_nsec) assert_equal(123456789, Time.parse("2000-01-01T00:00:00.123456789+00:00").tv_nsec) end + + def test_huge_precision + bug4456 = '[ruby-dev:43284]' + assert_normal_exit %q{ Time.now.strftime("%1000000000F") }, bug4456 + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/