summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--test/ruby/test_time.rb9
-rw-r--r--test/ruby/test_time_tz.rb1
-rw-r--r--time.c2
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 <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)
}
}
}
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());
}