lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 2014-02-21 08:35, René Rebe wrote:

it does NOT say:

MAY copy, or clobber, additional bytes after the \n was encountered.

It *does* say this implicitly, i.e. it *does not* say this is
prohibited. In the simplest case, ,,fgets()'' can memset all an outut
buffer with zeroes at the beginning of its operation to verify that all
the buffer is writable. Untouched buffer is present solely in an
EOF-at-the-beginning case.

{To René: Your patch has one major disadvantage: it assumes that
the buffer will not be touched beyond terminating null character. In
general it *is not* true. Lua is sitting on top of C and not on top of
your implementation of C.}

,,fgets'' *is not* for reading zeroes (no matter: from text or from
binary streams). Using ,,fgets'' is ,,implementation detail'' which
should be mentioned in a documentation at least (or maybe, at most?).

BTW. It is unreasonable, how many can be told about differences between
text/binary streams, in the world, where 99.99% implementations *does
not* distinguish between them. :-)

-- best regards

Cezary H. Noweta