In perl.git, the branch tonyc/readline-fixed has been updated <http://perl5.git.perl.org/perl.git/commitdiff/83f21b046e129de1b6ba8a8efbdda658fad53c88?hp=93edbb1a11bf2a632f9eaba5b43123a6fc40a024>
- Log ----------------------------------------------------------------- commit 83f21b046e129de1b6ba8a8efbdda658fad53c88 Author: Tony Cook <[email protected]> Date: Sat Mar 17 01:10:36 2012 +1100 fix a fencepost error I found trying to fall asleep ----------------------------------------------------------------------- Summary of changes: sv.c | 5 +++-- t/io/utf8.t | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sv.c b/sv.c index cacb17d..6a303cc 100644 --- a/sv.c +++ b/sv.c @@ -7609,10 +7609,11 @@ S_sv_gets_read_record(pTHX_ SV *const sv, PerlIO *const fp, I32 append) } } - if (!charstart) { + if (charcount < recsize) { /* read the rest of the current character, and maybe the beginning of the next, if we need it */ - STRLEN readsize = skip - (bend - bufp) + (charcount + 1 < recsize); + STRLEN readsize = (charstart ? 0 : skip - (bend - bufp)) + + (charcount + 1 < recsize); STRLEN bufp_offset = bufp - buffer; ssize_t morebytesread; diff --git a/t/io/utf8.t b/t/io/utf8.t index ed535a3..919b734 100644 --- a/t/io/utf8.t +++ b/t/io/utf8.t @@ -10,7 +10,7 @@ BEGIN { no utf8; # needed for use utf8 not griping about the raw octets -plan(tests => 58); +plan(tests => 59); $| = 1; @@ -354,6 +354,7 @@ is($failed, undef); open F, ">:utf8", $a_file; print F "foo\xE4"; print F "bar\xFE"; + print F "a\xE4a"; close F; open F, "<:utf8", $a_file; local $/ = \4; @@ -361,6 +362,8 @@ is($failed, undef); is($line, "foo\xE4", "readline with \$/ = \\4"); $line .= <F>; is($line, "foo\xE4bar\xFE", "rcatline with \$/ = \\4"); + $line = <F>; + is($line, "a\xE4a", "readline with boundary condition"); close F; # badly encoded at EOF -- Perl5 Master Repository
