mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aed90c7cae
commit
6b47d60e16
4 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Sat May 14 12:20:22 2011 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||||
|
|
||||||
|
* 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@tenderlovemaking.com>
|
Sat Feb 26 07:10:05 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
* ext/psych/lib/psych/scalar_scanner.rb: fix parsing timezone's whose
|
* ext/psych/lib/psych/scalar_scanner.rb: fix parsing timezone's whose
|
||||||
|
|
|
@ -309,6 +309,7 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str
|
||||||
i = rb_strftime_with_timespec(s, endp - s, fmt, vtm, timev, ts, gmt); \
|
i = rb_strftime_with_timespec(s, endp - s, fmt, vtm, timev, ts, gmt); \
|
||||||
if (!i) return 0; \
|
if (!i) return 0; \
|
||||||
if (precision > i) {\
|
if (precision > i) {\
|
||||||
|
NEEDS(precision); \
|
||||||
memmove(s + precision - i, s, i);\
|
memmove(s + precision - i, s, i);\
|
||||||
memset(s, padding ? padding : ' ', precision - i); \
|
memset(s, padding ? padding : ' ', precision - i); \
|
||||||
s += precision; \
|
s += precision; \
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
require 'time'
|
require 'time'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
require_relative 'ruby/envutil.rb'
|
||||||
|
|
||||||
class TestTimeExtension < Test::Unit::TestCase # :nodoc:
|
class TestTimeExtension < Test::Unit::TestCase # :nodoc:
|
||||||
def test_rfc822
|
def test_rfc822
|
||||||
|
@ -397,4 +398,9 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
|
||||||
assert_equal(123456789, Time.xmlschema("2000-01-01T00:00:00.123456789+00:00").tv_nsec)
|
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)
|
assert_equal(123456789, Time.parse("2000-01-01T00:00:00.123456789+00:00").tv_nsec)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_huge_precision
|
||||||
|
bug4456 = '[ruby-dev:43284]'
|
||||||
|
assert_normal_exit %q{ Time.now.strftime("%1000000000F") }, bug4456
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#define RUBY_VERSION "1.9.2"
|
#define RUBY_VERSION "1.9.2"
|
||||||
#define RUBY_PATCHLEVEL 208
|
#define RUBY_PATCHLEVEL 209
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
#define RUBY_VERSION_MINOR 9
|
#define RUBY_VERSION_MINOR 9
|
||||||
#define RUBY_VERSION_TEENY 1
|
#define RUBY_VERSION_TEENY 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue