diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-18 05:26:07 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-18 05:26:07 +0000 |
commit | 58f269d070fb404f7e78ee7153a01462ab87bdb9 (patch) | |
tree | 0ed5dc8495b5b0997212b09da6f750fae08dd4ef | |
parent | 815d88b569d9b2ceb480c7ce76b429257199a5c7 (diff) |
merge revision(s) 34433: [Backport #6153]
* encoding.c (rb_enc_compatible): return ASCII-8BIT even if 2nd string
is ascii only string. [ruby-core:42354] [Bug #5968]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | encoding.c | 1 | ||||
-rw-r--r-- | test/ruby/test_encoding.rb | 14 | ||||
-rw-r--r-- | version.h | 6 |
4 files changed, 22 insertions, 4 deletions
@@ -1,3 +1,8 @@ +Sun Mar 18 13:23:28 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * encoding.c (rb_enc_compatible): return ASCII-8BIT even if 2nd string + is ascii only string. [ruby-core:42354] [Bug #5968] + Tue Mar 6 18:55:37 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> * lib/test/unit/assertions.rb (assert_send, assert_not_send): diff --git a/encoding.c b/encoding.c index 18f54e684c..b8c5f6d357 100644 --- a/encoding.c +++ b/encoding.c @@ -804,7 +804,6 @@ rb_enc_compatible(VALUE str1, VALUE str2) if (cr2 == ENC_CODERANGE_7BIT) return enc1; } if (cr2 == ENC_CODERANGE_7BIT) { - if (idx1 == ENCINDEX_ASCII) return enc2; return enc1; } } diff --git a/test/ruby/test_encoding.rb b/test/ruby/test_encoding.rb index 6a406ae237..ef2dc39c4d 100644 --- a/test/ruby/test_encoding.rb +++ b/test/ruby/test_encoding.rb @@ -99,4 +99,18 @@ class TestEncoding < Test::Unit::TestCase str2 = Marshal.load(Marshal.dump(str2)) assert_equal(str, str2, '[ruby-dev:38596]') end + + def test_unsafe + bug5279 = '[ruby-dev:44469]' + assert_ruby_status([], '$SAFE=4; "a".encode("utf-16be")', bug5279) + end + + def test_compatible_p + ua = "abc".force_encoding(Encoding::UTF_8) + assert_equal(Encoding::UTF_8, Encoding.compatible?(ua, :abc)) + assert_equal(nil, Encoding.compatible?(ua, 1)) + bin = "a".force_encoding(Encoding::ASCII_8BIT) + asc = "b".force_encoding(Encoding::US_ASCII) + assert_equal(Encoding::ASCII_8BIT, Encoding.compatible?(bin, asc)) + end end @@ -1,10 +1,10 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 164 +#define RUBY_PATCHLEVEL 165 -#define RUBY_RELEASE_DATE "2012-03-16" +#define RUBY_RELEASE_DATE "2012-03-18" #define RUBY_RELEASE_YEAR 2012 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 16 +#define RUBY_RELEASE_DAY 18 #include "ruby/version.h" |