mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@67391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f86e5daee7
commit
7a27746ece
3 changed files with 22 additions and 3 deletions
6
io.c
6
io.c
|
@ -3017,6 +3017,12 @@ rb_io_getline_fast(rb_io_t *fptr, rb_encoding *enc, int chomp)
|
||||||
read_buffered_data(RSTRING_PTR(str)+len, pending - chomplen, fptr);
|
read_buffered_data(RSTRING_PTR(str)+len, pending - chomplen, fptr);
|
||||||
fptr->rbuf.off += chomplen;
|
fptr->rbuf.off += chomplen;
|
||||||
fptr->rbuf.len -= 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;
|
len += pending - chomplen;
|
||||||
if (cr != ENC_CODERANGE_BROKEN)
|
if (cr != ENC_CODERANGE_BROKEN)
|
||||||
|
|
|
@ -228,6 +228,19 @@ class TestIO < Test::Unit::TestCase
|
||||||
assert_nil r.gets
|
assert_nil r.gets
|
||||||
r.close
|
r.close
|
||||||
end)
|
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
|
end
|
||||||
|
|
||||||
def test_gets_chomp_rs_nil
|
def test_gets_chomp_rs_nil
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#define RUBY_VERSION "2.4.6"
|
#define RUBY_VERSION "2.4.6"
|
||||||
#define RUBY_RELEASE_DATE "2019-03-19"
|
#define RUBY_RELEASE_DATE "2019-03-31"
|
||||||
#define RUBY_PATCHLEVEL 352
|
#define RUBY_PATCHLEVEL 353
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2019
|
#define RUBY_RELEASE_YEAR 2019
|
||||||
#define RUBY_RELEASE_MONTH 3
|
#define RUBY_RELEASE_MONTH 3
|
||||||
#define RUBY_RELEASE_DAY 19
|
#define RUBY_RELEASE_DAY 31
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue