From 9759173cfc954f89a24dd96a42067161a34bd243 Mon Sep 17 00:00:00 2001 From: eregon Date: Sun, 22 Feb 2015 22:26:55 +0000 Subject: * time.c: zone encoding should be US-ASCII if all 7-bits. Fix r46907. * test/ruby/test_time.rb, test/ruby/test_time_tz.rb: Update tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_time.rb | 9 ++++++--- test/ruby/test_time_tz.rb | 1 + time.c | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb761a635e..cd25d700e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Feb 23 07:25:29 2015 Benoit Daloze + + * time.c: Zone encoding should be US-ASCII if all 7-bits. Fix r46907. + + * test/ruby/test_time.rb, test/ruby/test_time_tz.rb: Update tests. + Sun Feb 22 18:33:42 2015 SHIBATA Hiroshi * common.mk: use ruby organization for rubyspec. diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index d0ded0ddf2..f4fb5bf3b3 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -527,9 +527,12 @@ class TestTime < Test::Unit::TestCase def assert_zone_encoding(time) zone = time.zone assert_predicate(zone, :valid_encoding?) - return if zone.ascii_only? - enc = Encoding.default_internal || Encoding.find('locale') - assert_equal(enc, zone.encoding) + if zone.ascii_only? + assert_equal(Encoding::US_ASCII, zone.encoding) + else + enc = Encoding.default_internal || Encoding.find('locale') + assert_equal(enc, zone.encoding) + end end def test_zone diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb index 736a3c16db..a73bd86f0b 100644 --- a/test/ruby/test_time_tz.rb +++ b/test/ruby/test_time_tz.rb @@ -267,6 +267,7 @@ class TestTimeTZ < Test::Unit::TestCase assert_equal(format_gmtoff(gmtoff), t.strftime("%z")) assert_equal(format_gmtoff(gmtoff, true), t.strftime("%:z")) assert_equal(format_gmtoff2(gmtoff), t.strftime("%::z")) + assert_equal(Encoding::US_ASCII, t.zone.encoding) } } } diff --git a/time.c b/time.c index 044a049981..cda91a38a6 100644 --- a/time.c +++ b/time.c @@ -4194,7 +4194,7 @@ time_isdst(VALUE time) static VALUE time_zone_name(const char *zone) { - VALUE name = rb_str_new_cstr(zone); + VALUE name = rb_usascii_str_new_cstr(zone); if (!rb_enc_str_asciionly_p(name)) { name = rb_external_str_with_enc(name, rb_locale_encoding()); } -- cgit v1.2.3