diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-07 05:11:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-07 05:11:46 +0000 |
commit | 23488589b38f09a95e7ba61a72b12358ad6185cb (patch) | |
tree | a9e848750fffdea22e2860c4e3825479e2a8abc0 /io.c | |
parent | 1598b5e7b343b6c05e6cab47ac3878276aea6d37 (diff) | |
download | ruby-23488589b38f09a95e7ba61a72b12358ad6185cb.tar.gz |
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/trunk@67188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -3310,6 +3310,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) |