Eric Blake wrote:
> The workaround would be
> to see if lseek returns a non-negative number; and if so, read the
> internals of the FILE to see how many bytes remain in the read buffer (the
> default buffer size is 4k); then since the file is seekable, temporarily
> swap the fd into O_BINARY mode, reread the buffer, count how many raw \n
> occur, then convert the fd back to O_TEXT before returning the corrected
> answer.  The workaround would also have to handle ^Z.

Indeed, that should work. (If the number of bytes in the buffer is n,
you might need to go back by up to 2*n bytes.) Bravo! Since this effort is
for only one implementation, it appears doable and maintainable.

Bruno



Reply via email to