ruby-changes:55184
From: usa <ko1@a...>
Date: Sun, 31 Mar 2019 23:58:29 +0900 (JST)
Subject: [ruby-changes:55184] usa:r67391 (ruby_2_4): merge revision(s) 67188: [Backport #15642]
usa 2019-03-31 23:58:24 +0900 (Sun, 31 Mar 2019) New Revision: 67391 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67391 Log: merge revision(s) 67188: [Backport #15642] io.c: chomp CR at the end of read buffer * io.c (rb_io_getline_fast): chomp CR followed by LF but separated by the read buffer boundary. [ruby-core:91707] [Bug #15642] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/io.c branches/ruby_2_4/test/ruby/test_io.rb branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 67390) +++ ruby_2_4/version.h (revision 67391) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.6" -#define RUBY_RELEASE_DATE "2019-03-19" -#define RUBY_PATCHLEVEL 352 +#define RUBY_RELEASE_DATE "2019-03-31" +#define RUBY_PATCHLEVEL 353 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 19 +#define RUBY_RELEASE_DAY 31 #include "ruby/version.h" Index: ruby_2_4/test/ruby/test_io.rb =================================================================== --- ruby_2_4/test/ruby/test_io.rb (revision 67390) +++ ruby_2_4/test/ruby/test_io.rb (revision 67391) @@ -228,6 +228,19 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_io.rb#L228 assert_nil r.gets r.close end) + + (0..3).each do |i| + pipe(proc do |w| + w.write("a" * ((4096 << i) - 4) + "\r\n" "a\r\n") + w.close + end, + proc do |r| + r.gets + assert_equal "a", r.gets(chomp: true) + assert_nil r.gets + r.close + end) + end end def test_gets_chomp_rs_nil Index: ruby_2_4/io.c =================================================================== --- ruby_2_4/io.c (revision 67390) +++ ruby_2_4/io.c (revision 67391) @@ -3017,6 +3017,12 @@ rb_io_getline_fast(rb_io_t *fptr, rb_enc https://github.com/ruby/ruby/blob/trunk/ruby_2_4/io.c#L3017 read_buffered_data(RSTRING_PTR(str)+len, pending - chomplen, fptr); fptr->rbuf.off += chomplen; fptr->rbuf.len -= chomplen; + if (pending == 1 && chomplen == 1 && len > 0) { + if (RSTRING_PTR(str)[len-1] == '\r') { + rb_str_resize(str, --len); + break; + } + } } len += pending - chomplen; if (cr != ENC_CODERANGE_BROKEN) Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 67390) +++ ruby_2_4 (revision 67391) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r67188 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/