ruby-changes:27926
From: usa <ko1@a...>
Date: Thu, 28 Mar 2013 18:14:02 +0900 (JST)
Subject: [ruby-changes:27926] usa:r39978 (ruby_1_9_3): merge revision(s) 39495: [Backport #7954]
usa 2013-03-28 18:13:48 +0900 (Thu, 28 Mar 2013) New Revision: 39978 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39978 Log: merge revision(s) 39495: [Backport #7954] * string.c (str_byte_substr): don't set coderange if it's not known. [Bug #7954] [ruby-dev:47108] Modified directories: branches/ruby_1_9_3/ Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/string.c branches/ruby_1_9_3/test/ruby/test_string.rb branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 39977) +++ ruby_1_9_3/ChangeLog (revision 39978) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1 +Thu Mar 28 18:13:38 2013 NARUSE, Yui <naruse@r...> + + * string.c (str_byte_substr): don't set coderange if it's not known. + [Bug #7954] [ruby-dev:47108] + Thu Mar 28 18:12:19 2013 Kouhei Sutou <kou@c...> * lib/rexml/document.rb: move entity_expansion_text_limit accessor to ... Index: ruby_1_9_3/string.c =================================================================== --- ruby_1_9_3/string.c (revision 39977) +++ ruby_1_9_3/string.c (revision 39978) @@ -4041,10 +4041,29 @@ str_byte_substr(VALUE str, long beg, lon https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/string.c#L4041 } else { str2 = rb_str_new5(str, p, len); - rb_enc_cr_str_copy_for_substr(str2, str); - OBJ_INFECT(str2, str); } + str_enc_copy(str2, str); + + if (RSTRING_LEN(str2) == 0) { + if (!rb_enc_asciicompat(STR_ENC_GET(str))) + ENC_CODERANGE_SET(str2, ENC_CODERANGE_VALID); + else + ENC_CODERANGE_SET(str2, ENC_CODERANGE_7BIT); + } + else { + switch (ENC_CODERANGE(str)) { + case ENC_CODERANGE_7BIT: + ENC_CODERANGE_SET(str2, ENC_CODERANGE_7BIT); + break; + default: + ENC_CODERANGE_SET(str2, ENC_CODERANGE_UNKNOWN); + break; + } + } + + OBJ_INFECT(str2, str); + return str2; } Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 39977) +++ ruby_1_9_3/version.h (revision 39978) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1 #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 395 +#define RUBY_PATCHLEVEL 396 #define RUBY_RELEASE_DATE "2013-03-28" #define RUBY_RELEASE_YEAR 2013 Index: ruby_1_9_3/test/ruby/test_string.rb =================================================================== --- ruby_1_9_3/test/ruby/test_string.rb (revision 39977) +++ ruby_1_9_3/test/ruby/test_string.rb (revision 39978) @@ -1995,5 +1995,9 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_string.rb#L1995 assert_equal(u("\x81\x82"), "\u3042".byteslice(1..2)) assert_equal(u("\x82")+("\u3042"*9), ("\u3042"*10).byteslice(2, 28)) + + bug7954 = '[ruby-dev:47108]' + assert_equal(false, "\u3042".byteslice(0, 2).valid_encoding?) + assert_equal(false, ("\u3042"*10).byteslice(0, 20).valid_encoding?) end end Property changes on: ruby_1_9_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r39495,39706 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/