diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-25 14:46:11 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-25 14:46:11 +0000 |
| commit | 3e26b9514563b477982444d755156e85279e84bc (patch) | |
| tree | e598c1ea2966b52481072523c1b8ab8bcafe1c44 | |
| parent | f935d5f4f6eb3c9241ff94b2237fb022a350413b (diff) | |
merges r24509 from trunk into ruby_1_9_1.
--
* string.c (rb_str_new_frozen): must not change encoding of frozen
shared string. [ruby-dev:39068]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@25477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | string.c | 7 | ||||
| -rw-r--r-- | test/ruby/test_string.rb | 13 | ||||
| -rw-r--r-- | version.h | 2 |
4 files changed, 23 insertions, 4 deletions
@@ -1,3 +1,8 @@ +Wed Aug 12 12:59:51 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * string.c (rb_str_new_frozen): must not change encoding of frozen + shared string. [ruby-dev:39068] + Fri Oct 23 10:51:04 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp> * test/ruby/test_m17n.rb (TestM17N#test_sprintf_s): @@ -666,13 +666,14 @@ rb_str_new_frozen(VALUE orig) long ofs; ofs = RSTRING_LEN(str) - RSTRING_LEN(orig); if ((ofs > 0) || (klass != RBASIC(str)->klass) || - (!OBJ_TAINTED(str) && OBJ_TAINTED(orig))) { + (!OBJ_TAINTED(str) && OBJ_TAINTED(orig)) || + ENCODING_GET(str) != ENCODING_GET(orig)) { str = str_new3(klass, str); RSTRING(str)->as.heap.ptr += ofs; RSTRING(str)->as.heap.len -= ofs; + rb_enc_cr_str_exact_copy(str, orig); + OBJ_INFECT(str, orig); } - rb_enc_cr_str_exact_copy(str, orig); - OBJ_INFECT(str, orig); } else if (STR_EMBED_P(orig)) { str = str_new(klass, RSTRING_PTR(orig), RSTRING_LEN(orig)); diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index bf0ed6a830..7e9176e507 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1786,4 +1786,17 @@ class TestString < Test::Unit::TestCase ("aaaaaaaa".."zzzzzzzz").each {|s| s.to_sym } INPUT end + + def test_shared_force_encoding + s = "\u{3066}\u{3059}\u{3068}".gsub(//, '') + h = {} + h[s] = nil + k = h.keys[0] + assert_equal(s, k, '[ruby-dev:39068]') + assert_equal(Encoding::UTF_8, k.encoding, '[ruby-dev:39068]') + s.dup.force_encoding(Encoding::ASCII_8BIT).gsub(//, '') + k = h.keys[0] + assert_equal(s, k, '[ruby-dev:39068]') + assert_equal(Encoding::UTF_8, k.encoding, '[ruby-dev:39068]') + end end @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.1" -#define RUBY_PATCHLEVEL 285 +#define RUBY_PATCHLEVEL 286 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 |
