summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
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 7de405de32..07c678f855 100644
--- a/io.c
+++ b/io.c
@@ -3306,6 +3306,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)