summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-21 06:37:18 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-21 06:37:18 +0000
commit4131d6176ac46da95b1e7fa045651783f0a66c65 (patch)
tree183d949381d2319ad4fe8471f2632f8e86839ca2 /io.c
parent2976ec58a48e3ff83ff3d0979041bb5694592153 (diff)
* io.c (io_getc): fix incomplete character immediately before EOF
with newline converter. [ruby-dev:41024] run test only when "Create Shortcut (&S)" menu is found. * lib/rexml/parsers/xpathparser.rb (PathExpr): ditto. * lib/matrix.rb (Vector#each): make Vector enumerable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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;
}