ruby-changes:50020
From: usa <ko1@a...>
Date: Wed, 31 Jan 2018 22:28:43 +0900 (JST)
Subject: [ruby-changes:50020] usa:r62138 (ruby_2_3): merge revision(s) 60059: [Backport #13949]
usa 2018-01-31 22:28:39 +0900 (Wed, 31 Jan 2018) New Revision: 62138 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62138 Log: merge revision(s) 60059: [Backport #13949] pack.c: unpack "M" may be ASCII only * pack.c (pack_unpack_internal): set ASCII only properly on "M", may be ASCII only. [ruby-core:83055] [Bug #13949] Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/ChangeLog branches/ruby_2_3/pack.c branches/ruby_2_3/test/ruby/test_pack.rb branches/ruby_2_3/version.h Index: ruby_2_3/pack.c =================================================================== --- ruby_2_3/pack.c (revision 62137) +++ ruby_2_3/pack.c (revision 62138) @@ -1706,6 +1706,7 @@ pack_unpack(VALUE str, VALUE fmt) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/pack.c#L1706 { VALUE buf = infected_str_new(0, send - s, str); char *ptr = RSTRING_PTR(buf), *ss = s; + int csum = 0; int c1, c2; while (s < send) { @@ -1717,18 +1718,19 @@ pack_unpack(VALUE str, VALUE fmt) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/pack.c#L1718 if ((c1 = hex2num(*s)) == -1) break; if (++s == send) break; if ((c2 = hex2num(*s)) == -1) break; - *ptr++ = castchar(c1 << 4 | c2); + csum |= *ptr++ = castchar(c1 << 4 | c2); } } else { - *ptr++ = *s; + csum |= *ptr++ = *s; } s++; ss = s; } rb_str_set_len(buf, ptr - RSTRING_PTR(buf)); rb_str_buf_cat(buf, ss, send-ss); - ENCODING_CODERANGE_SET(buf, rb_ascii8bit_encindex(), ENC_CODERANGE_VALID); + csum = ISASCII(csum) ? ENC_CODERANGE_7BIT : ENC_CODERANGE_VALID; + ENCODING_CODERANGE_SET(buf, rb_ascii8bit_encindex(), csum); UNPACK_PUSH(buf); } break; Index: ruby_2_3/ChangeLog =================================================================== --- ruby_2_3/ChangeLog (revision 62137) +++ ruby_2_3/ChangeLog (revision 62138) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1 +Wed Jan 31 22:28:20 2018 Nobuyoshi Nakada <nobu@r...> + + pack.c: unpack "M" may be ASCII only + + * pack.c (pack_unpack_internal): set ASCII only properly on "M", + may be ASCII only. [ruby-core:83055] [Bug #13949] + Wed Jan 31 22:26:13 2018 Nobuyoshi Nakada <nobu@r...> string.c: ASCII-incompatible is not ASCII only Index: ruby_2_3/test/ruby/test_pack.rb =================================================================== --- ruby_2_3/test/ruby/test_pack.rb (revision 62137) +++ ruby_2_3/test/ruby/test_pack.rb (revision 62138) @@ -686,6 +686,11 @@ EXPECTED https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_pack.rb#L686 assert_equal(["pre=hoge"], "pre=hoge".unpack("M")) assert_equal(["pre==31after"], "pre==31after".unpack("M")) assert_equal(["pre===31after"], "pre===31after".unpack("M")) + + bug = '[ruby-core:83055] [Bug #13949]' + s = "abcdef".unpack("M").first + assert_equal(Encoding::ASCII_8BIT, s.encoding) + assert_predicate(s, :ascii_only?, bug) end def test_pack_unpack_P2 Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 62137) +++ ruby_2_3/version.h (revision 62138) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.7" #define RUBY_RELEASE_DATE "2018-01-31" -#define RUBY_PATCHLEVEL 399 +#define RUBY_PATCHLEVEL 400 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 1 Index: ruby_2_3 =================================================================== --- ruby_2_3 (revision 62137) +++ ruby_2_3 (revision 62138) Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r60059 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/