u8-istream: Fix handling of partial reads.
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 9 Sep 2014 15:51:44 +0000 (08:51 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 9 Sep 2014 15:51:44 +0000 (08:51 -0700)
commit287f1aa484434ad1817de8623ba3b092e26733a9
tree94333307c08c5d033aec98756b53740fbeb001ab
parent7db742758d6aa172fb995aa2e109fb92b8ccc4c2
u8-istream: Fix handling of partial reads.

The u8-istream code did not retry upon a partial read, assuming that that
was the end of the file.  When the partial read was shorter than
ENCODING_GUESS_MIN, this could cause the encoding guesser, in turn, to
guess the wrong encoding (especially if the encoding was really UTF-16 and
the partial read was an odd number of bytes).

Reported at https://bugs.debian.org/760841.
Reported by Friedrich Beckmann and Steven Chamberlain.
src/libpspp/u8-istream.c
tests/libpspp/u8-istream.at