diff --git a/ChangeLog b/ChangeLog index 37687ce2b5..f7144b218b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 24 16:31:04 2008 Yukihiro Matsumoto + + * io.c (rb_io_getline_fast): the end point of left_char_head() + must be the last character. [ruby-cvs:22445] + Thu Jan 24 16:24:25 2008 NAKAMURA Usaku * parse.y (reg_fragment_setenc_gen): recognize regexp with option n as diff --git a/io.c b/io.c index 79f2396383..10b1d9b582 100644 --- a/io.c +++ b/io.c @@ -1799,12 +1799,14 @@ rb_io_getline_fast(rb_io_t *fptr) if (pending > 0) { const char *p = READ_DATA_PENDING_PTR(fptr); + const char *pend = p + pending - 1; const char *e; e = memchr(p, '\n', pending); if (e) { const char *p0 = rb_enc_left_char_head(p, e, enc); - const char *pend = rb_enc_left_char_head(p, p+pending, enc); + + pend = rb_enc_left_char_head(p0, pend, enc); if (rb_enc_is_newline(p0, pend, enc)) { pending = p0 - p + rb_enc_mbclen(p0, pend, enc); }