diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-22 22:26:55 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-22 22:26:55 +0000 |
commit | 9759173cfc954f89a24dd96a42067161a34bd243 (patch) | |
tree | 2886db0d42f3feef29ed65dbcbb073a17e86d274 | |
parent | 6d6b33e6e5dde12f258ad85bba6475af0aab75cf (diff) | |
download | ruby-9759173cfc954f89a24dd96a42067161a34bd243.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | test/ruby/test_time.rb | 9 | ||||
-rw-r--r-- | test/ruby/test_time_tz.rb | 1 | ||||
-rw-r--r-- | time.c | 2 |
4 files changed, 14 insertions, 4 deletions
@@ -1,3 +1,9 @@ +Mon Feb 23 07:25:29 2015 Benoit Daloze <eregontp@gmail.com> + + * 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 <shibata.hiroshi@gmail.com> * 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) } } } @@ -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()); } |