diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-15 07:08:12 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-15 07:08:12 +0000 |
commit | 443b1517cfbee8cf3a0c44f040939edf4f94b9a0 (patch) | |
tree | 578f56eec5a5e56a5a7025147994631ea72eed31 | |
parent | 7da18cf1a25a373285eab1e317d8439713cd0d89 (diff) | |
download | ruby-443b1517cfbee8cf3a0c44f040939edf4f94b9a0.tar.gz |
* string.c (rb_enc_cr_str_buf_cat): remove special treatment of
ASCII-8BIT receivers.
* string.c (str_gsub): set initial encoding of the buffer as the
same of the receiver. [ruby-core:35141]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | string.c | 6 | ||||
-rw-r--r-- | test/ruby/test_m17n.rb | 4 |
3 files changed, 13 insertions, 5 deletions
@@ -1,3 +1,11 @@ +Tue Feb 15 15:39:37 2011 NARUSE, Yui <naruse@ruby-lang.org> + + * string.c (rb_enc_cr_str_buf_cat): remove special treatment of + ASCII-8BIT receivers. + + * string.c (str_gsub): set initial encoding of the buffer as the + same of the receiver. [ruby-core:35141] + Tue Feb 15 09:49:33 2011 NAKAMURA Usaku <usa@ruby-lang.org> * test/ruby/test_system.rb (TestSystem#test_system_at): use findstr @@ -1899,7 +1899,6 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len, int str_encindex = ENCODING_GET(str); int res_encindex; int str_cr, res_cr; - int str_a8 = ENCODING_IS_ASCII8BIT(str); int ptr_a8 = ptr_encindex == 0; str_cr = ENC_CODERANGE(str); @@ -1930,7 +1929,7 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len, ptr_cr = coderange_scan(ptr, len, ptr_enc); } if (str_cr == ENC_CODERANGE_UNKNOWN) { - if (str_a8 || ptr_cr != ENC_CODERANGE_7BIT) { + if (ENCODING_IS_ASCII8BIT(str) || ptr_cr != ENC_CODERANGE_7BIT) { str_cr = rb_enc_str_coderange(str); } } @@ -1953,7 +1952,7 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len, } else if (str_cr == ENC_CODERANGE_7BIT) { if (ptr_cr == ENC_CODERANGE_7BIT) { - res_encindex = !str_a8 ? str_encindex : ptr_encindex; + res_encindex = str_encindex; res_cr = ENC_CODERANGE_7BIT; } else { @@ -3746,6 +3745,7 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang) cp = sp; str_enc = STR_ENC_GET(str); rb_enc_associate(dest, str_enc); + ENC_CODERANGE_SET(dest, rb_enc_asciicompat(str_enc) ? ENC_CODERANGE_7BIT : ENC_CODERANGE_VALID); do { n++; diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 799e46073c..c8d2d0116c 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -1098,8 +1098,8 @@ class TestM17N < Test::Unit::TestCase s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4") assert_equal(e("\xa3\xb0z\xa3\xb2\xa3\xb3\xa3\xb4"), s.gsub(/\xa3\xb1/e, "z")) - assert_equal(Encoding::EUC_JP, (a("").gsub(//) { e("") }.encoding)) - assert_equal(Encoding::EUC_JP, (a("a").gsub(/a/) { e("") }.encoding)) + assert_equal(Encoding::ASCII_8BIT, (a("").gsub(//) { e("") }.encoding)) + assert_equal(Encoding::ASCII_8BIT, (a("a").gsub(/a/) { e("") }.encoding)) end def test_end_with |