ruby-changes:54974
From: naruse <ko1@a...>
Date: Wed, 6 Mar 2019 17:53:54 +0900 (JST)
Subject: [ruby-changes:54974] naruse:r67181 (ruby_2_6): merge revision(s) 67167: [Backport #15635]
naruse 2019-03-06 17:53:51 +0900 (Wed, 06 Mar 2019) New Revision: 67181 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67181 Log: merge revision(s) 67167: [Backport #15635] string.c: respect the actual encoding * string.c (rb_enc_str_coderange): respect the actual encoding of if a BOM presents, and scan for the actual code range. [ruby-core:91662] [Bug #15635] Modified directories: branches/ruby_2_6/ Modified files: branches/ruby_2_6/string.c branches/ruby_2_6/test/ruby/test_m17n.rb branches/ruby_2_6/version.h Index: ruby_2_6/version.h =================================================================== --- ruby_2_6/version.h (revision 67180) +++ ruby_2_6/version.h (revision 67181) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_6/version.h#L1 #define RUBY_VERSION "2.6.1" #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 38 +#define RUBY_PATCHLEVEL 39 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_6/string.c =================================================================== --- ruby_2_6/string.c (revision 67180) +++ ruby_2_6/string.c (revision 67181) @@ -657,12 +657,13 @@ rb_enc_str_coderange(VALUE str) https://github.com/ruby/ruby/blob/trunk/ruby_2_6/string.c#L657 if (cr == ENC_CODERANGE_UNKNOWN) { int encidx = ENCODING_GET(str); rb_encoding *enc = rb_enc_from_index(encidx); - if (rb_enc_mbminlen(enc) > 1 && rb_enc_dummy_p(enc)) { + if (rb_enc_mbminlen(enc) > 1 && rb_enc_dummy_p(enc) && + rb_enc_mbminlen(enc = get_actual_encoding(encidx, str)) == 1) { cr = ENC_CODERANGE_BROKEN; } else { cr = coderange_scan(RSTRING_PTR(str), RSTRING_LEN(str), - get_actual_encoding(encidx, str)); + enc); } ENC_CODERANGE_SET(str, cr); } Index: ruby_2_6/test/ruby/test_m17n.rb =================================================================== --- ruby_2_6/test/ruby/test_m17n.rb (revision 67180) +++ ruby_2_6/test/ruby/test_m17n.rb (revision 67181) @@ -269,6 +269,13 @@ class TestM17N < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_6/test/ruby/test_m17n.rb#L269 assert_empty(encs, bug10598) end + def test_utf_without_bom_valid + encs = [Encoding::UTF_16, Encoding::UTF_32].find_all {|enc| + !(+"abcd").encode!(enc).force_encoding(enc).valid_encoding? + } + assert_empty(encs) + end + def test_object_utf16_32_inspect EnvUtil.suppress_warning do begin Index: ruby_2_6 =================================================================== --- ruby_2_6 (revision 67180) +++ ruby_2_6 (revision 67181) Property changes on: ruby_2_6 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r67167 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/