summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/io.c b/io.c
index d74492a73e..f7bff6b0b0 100644
--- a/io.c
+++ b/io.c
@@ -2756,15 +2756,15 @@ io_getc(rb_io_t *fptr, rb_encoding *enc)
}
if (more_char(fptr) == MORE_CHAR_FINISHED) {
- clear_readconv(fptr);
- if (fptr->cbuf_len == 0)
- return Qnil;
+ if (fptr->cbuf_len == 0) {
+ clear_readconv(fptr);
+ return Qnil;
+ }
/* return an unit of an incomplete character just before EOF */
- r = rb_enc_mbclen(fptr->cbuf+fptr->cbuf_off,
- fptr->cbuf+fptr->cbuf_off+fptr->cbuf_len,
- read_enc);
- io_shift_cbuf(fptr, r, &str);
- str = io_enc_str(str, fptr);
+ str = rb_enc_str_new(fptr->cbuf+fptr->cbuf_off, 1, read_enc);
+ fptr->cbuf_off += 1;
+ fptr->cbuf_len -= 1;
+ if (fptr->cbuf_len == 0) clear_readconv(fptr);
ENC_CODERANGE_SET(str, ENC_CODERANGE_BROKEN);
return str;
}