lua-users home
lua-l archive

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


2014-02-20 21:44 GMT+02:00 René Rebe <rene@exactcode.de>:

> The discussion is about lines(), that it using fgets is just an
> implementation detail.
>
> If Roberto would not kind of implied performance loss is not that acceptable
> with his bible test case then a fgetc() look without all this troubles would
> have been very fine for me, too.
>
> I can certainly give up improving vanilla Lua and convincing some that
> random data loss is usually considered a bug, and live very happily with the
> fix that works for me just fine.
>
> Have fun parsing MIME, CGI data, or financial programs exports using \0
> field delimiters. Or wherever a zero comes along.

It is useful to look again at the start of the post where it all started.

>> I just noticed that io:lines() does not cope with \0 in the lines

Allow me to summarize the facts.

1. io.lines operates on text files.
2. Text files may not contain any control character except whitespace.
3. \0 is not whitespace.

In other words, the behaviour complained of is that a standard library
routine when given data that does not conform to specification gives
undefined results.

Of course. io.lines does not have super cow powers.