[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: io:lines() and \0
- From: Craig Barnes <craigbarnes85@...>
- Date: Fri, 21 Feb 2014 23:59:08 +0000
> 1) Mention in the manual that using f:lines() (or io.lines()) on a non-text
> file may produce inconsistent results. This maintains the status quo, but
> Lua cannot read a line of bytes containing embedded NUL bytes (that this
> comes up is interesting, but that the last time it came up was eight years
> ago also says something). This is the easiest solution (and for now, looks
> to be the one picked).
> [1] Had getline() (or getdelim()) not existed, and René used fgets() in
> a C implementation, I suspect he might have had to resort to strace
> to figure out why he wasn't getting all the data, or more data than
> expected. I only point this out as an observation.
I'm not so sure it's that obscure. I ran into this problem a couple of months
ago and it took maybe 10 minutes to hexdump the truncated lines to see
what was causing it and about 2 minutes to fix it:
https://github.com/craigbarnes/lua-gumbo/commit/168d9f3de5c1c082efc3a9d013873f79cba66919