summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-24 08:42:52 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-24 08:42:52 +0000
commit5d8bf153429dce73dde8a256580ac1412e469c02 (patch)
tree45c04212e7289321ff7917da81c6070068637c5d
parent6d90e595620d1b150aaf7c543ac4d56666d841b3 (diff)
merge revision(s) 49693,46907,49702,49710: [Backport #10887]
* 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. * time.c (time_zone_name): should be US-ASCII only if all 7-bits, otherwise locale encoding. [ruby-core:68230] [Bug #10887] * time.c (time_zone_name): should be US-ASCII only if all 7-bits, otherwise locale encoding. [ruby-core:68230] [Bug #10887] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@49719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog16
-rw-r--r--test/ruby/test_time.rb9
-rw-r--r--test/ruby/test_time_tz.rb1
-rw-r--r--time.c3
-rw-r--r--version.h2
5 files changed, 27 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 478ab9defc..6d4d13028e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+Tue Feb 24 17:41:27 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * time.c (time_zone_name): should be US-ASCII only if all 7-bits,
+ otherwise locale encoding. [ruby-core:68230] [Bug #10887]
+
+Tue Feb 24 17:41:27 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * time.c (time_zone_name): should be US-ASCII only if all 7-bits,
+ otherwise locale encoding. [ruby-core:68230] [Bug #10887]
+
+Tue Feb 24 17:41:27 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.
+
Tue Feb 24 16:37:26 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (chompped_length): enable smart chomp for all non-dummy
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 6f3e05f4cc..fb1ab9b7c8 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..4af193d19a 100644
--- a/time.c
+++ b/time.c
@@ -4198,6 +4198,9 @@ time_zone_name(const char *zone)
if (!rb_enc_str_asciionly_p(name)) {
name = rb_external_str_with_enc(name, rb_locale_encoding());
}
+ else {
+ rb_enc_associate(name, rb_usascii_encoding());
+ }
return name;
}
diff --git a/version.h b/version.h
index de73db6847..e2e468a273 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.0"
#define RUBY_RELEASE_DATE "2015-02-24"
-#define RUBY_PATCHLEVEL 81
+#define RUBY_PATCHLEVEL 82
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 2