ruby-changes:54984
From: nagachika <ko1@a...>
Date: Fri, 8 Mar 2019 00:19:39 +0900 (JST)
Subject: [ruby-changes:54984] nagachika:r67191 (ruby_2_5): merge revision(s) 67188: [Backport #15642]
nagachika 2019-03-08 00:19:34 +0900 (Fri, 08 Mar 2019) New Revision: 67191 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67191 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_5/ Modified files: branches/ruby_2_5/io.c branches/ruby_2_5/test/ruby/test_io.rb branches/ruby_2_5/version.h Index: ruby_2_5/version.h =================================================================== --- ruby_2_5/version.h (revision 67190) +++ ruby_2_5/version.h (revision 67191) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1 #define RUBY_VERSION "2.5.4" -#define RUBY_RELEASE_DATE "2019-03-06" -#define RUBY_PATCHLEVEL 141 +#define RUBY_RELEASE_DATE "2019-03-08" +#define RUBY_PATCHLEVEL 142 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 6 +#define RUBY_RELEASE_DAY 8 #include "ruby/version.h" Index: ruby_2_5/test/ruby/test_io.rb =================================================================== --- ruby_2_5/test/ruby/test_io.rb (revision 67190) +++ ruby_2_5/test/ruby/test_io.rb (revision 67191) @@ -228,6 +228,19 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_5/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_5/io.c =================================================================== --- ruby_2_5/io.c (revision 67190) +++ ruby_2_5/io.c (revision 67191) @@ -3241,6 +3241,12 @@ rb_io_getline_fast(rb_io_t *fptr, rb_enc https://github.com/ruby/ruby/blob/trunk/ruby_2_5/io.c#L3241 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_5 =================================================================== --- ruby_2_5 (revision 67190) +++ ruby_2_5 (revision 67191) Property changes on: ruby_2_5 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r67188 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/