summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-07 15:19:34 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-07 15:19:34 +0000
commit7bd41bd2cae0435301b46d845986c1410bbc8323 (patch)
tree9e2e0092afb191a410648cb423724f0eaccba627 /io.c
parent80266bfb39984cd6f1b9c5fed790a738fcd54d16 (diff)
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_5@67191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/io.c b/io.c
index 94facda8e7..1d190331d6 100644
--- a/io.c
+++ b/io.c
@@ -3241,6 +3241,12 @@ rb_io_getline_fast(rb_io_t *fptr, rb_encoding *enc, int chomp)
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)