lua-users home
lua-l archive

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

Hello again,

On Feb 17, 2014, at 16:55 , steve donovan wrote:

On Mon, Feb 17, 2014 at 5:51 PM, René Rebe <> wrote:
I just noticed that io:lines() does not cope with \0 in the lines, and thus
just returns truncated lines (lua-5.2.3, but legacy 5.1 likewise).

This is not surprising.  The whole idea of 'lines' only really applies
to text files, at least in my head ;)

Thinking about this a bit more - in my opinion this currently is a bug in the
Lua io library for a simple reason:

The returned line does not match what the C library returned. The effect
is that the C library reads more than the Lua wrapper in the io library returns,
and thus silently discards data.

A loop over the lines of any file should reproduce the file, given a reasonable
modern, C library, especially when the file is opened in binary mode.

Yes, this is mostly the fault of poor, decades old C library API -  but in my
opinion we should still handle it properly and fix this to match what the C
library returned.

I will work on a more performance patch, and hope it could potentially be


 ExactCODE GmbH, Jaegerstr. 67, DE-10117 Berlin | | | |