diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-17 04:25:56 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-17 04:25:56 +0000 |
commit | 0051d4a0778d8b81f22cdcac8a6af52fa567d5fe (patch) | |
tree | 7f9d2ef862a9b51a90ef035b2998efade8645a7f /io.c | |
parent | 04bbc1df1259e70064585dc23bacc7d904063f7e (diff) | |
download | ruby-0051d4a0778d8b81f22cdcac8a6af52fa567d5fe.tar.gz |
* include/ruby/encoding.h (rb_econv_putbackable): declared.
(rb_econv_putback): ditto.
* transcode.c (rb_econv_putbackable): implemented.
(rb_econv_putback): ditto.
* io.c (io_getc): put back bytes if possible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -2308,6 +2308,7 @@ io_getc(rb_io_t *fptr, rb_encoding *enc) const unsigned char *ss, *sp, *se; unsigned char *ds, *dp, *de; rb_econv_result_t res; + int putbackable; if (fptr->crbuf_len) { r = rb_enc_precise_mbclen(fptr->crbuf+fptr->crbuf_off, fptr->crbuf+fptr->crbuf_off+fptr->crbuf_len, fptr->enc); if (!MBCLEN_NEEDMORE_P(r)) @@ -2332,6 +2333,12 @@ io_getc(rb_io_t *fptr, rb_encoding *enc) fptr->rbuf_off += sp - ss; fptr->rbuf_len -= sp - ss; fptr->crbuf_len += dp - ds; + putbackable = rb_econv_putbackable(fptr->readconv); + if (putbackable) { + rb_econv_putback(fptr->readconv, (unsigned char *)fptr->rbuf + fptr->rbuf_off - putbackable, putbackable); + fptr->rbuf_off -= putbackable; + fptr->rbuf_len += putbackable; + } rb_econv_check_error(fptr->readconv); } if (MBCLEN_INVALID_P(r)) { |