From 0d0636d22ce7bd4729d749ca36cf2cde5175d815 Mon Sep 17 00:00:00 2001 From: yugui Date: Mon, 20 Dec 2010 13:22:48 +0000 Subject: merges r29848 and r29852 from trunk into ruby_1_9_2. -- * string.c (rb_str_concat): set ENC_CODERANGE_VALID when the receiver is 7BIT and the argument is non ASCII. -- Fix r29848's test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@30261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ string.c | 2 ++ test/ruby/test_m17n.rb | 6 ++++++ version.h | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9557d25cf6..0f5e2755ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Nov 22 11:58:11 2010 NARUSE, Yui + + * string.c (rb_str_concat): set ENC_CODERANGE_VALID when the + receiver is 7BIT and the argument is non ASCII. + Sat Nov 20 01:57:55 2010 Akio Tajima * common.mk: add dependency(insns.inc) to compile.obj diff --git a/string.c b/string.c index cdb919939b..1aae6120aa 100644 --- a/string.c +++ b/string.c @@ -2026,6 +2026,8 @@ rb_str_concat(VALUE str1, VALUE str2) } rb_str_resize(str1, pos+len); rb_enc_mbcput(lc, RSTRING_PTR(str1)+pos, enc); + if (cr == ENC_CODERANGE_7BIT && lc > 127) + cr = ENC_CODERANGE_VALID; ENC_CODERANGE_SET(str1, cr); return str1; } diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 3682d09898..3a71bd9bf0 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -1093,6 +1093,12 @@ class TestM17N < Test::Unit::TestCase assert_equal(a, s.each_char.to_a, "[ruby-dev:33211] #{encdump s}.each_char.to_a") end + def test_str_concat + assert_equal(1, "".concat(0xA2).size) + assert_equal("A\x84\x31\xA4\x39".force_encoding("GB18030"), + "A".force_encoding("GB18030") << 0x8431A439) + end + def test_regexp_match assert_equal([0,0], //.match("\xa1\xa1".force_encoding("euc-jp"),-1).offset(0)) assert_equal(0, // =~ :a) diff --git a/version.h b/version.h index 684bc97245..ae82d890d9 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 101 +#define RUBY_PATCHLEVEL 102 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -- cgit v1.2.3