lua-users home
lua-l archive

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



On Tue, Sep 5, 2017 at 9:29 PM, Oliver Kroth <oliver.kroth@nec-i.de> wrote:
 

If you have a single \n in your file. the first fp:read("*l") will return "", the second fp:read("*l") will return nil.
f you read from a file that contains some characters but no \n, you get nil.
So you get a non-nil for all \n-terminated lines.
and a nil for the rest, even if it contains some characters.

That's not what I am seeing on Lua 5.3.4 (macOS). If there's anything after the last \n it gets returned as a separate line.

Emacs by default does not append a \n at the end of the file, unless you explicitly add it, so files not ending in \n are easy to create.


--
--