lua-users home
lua-l archive

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


> > It seems to be impossible to detect if read('line*') stopped on an
> > newline or fileend. Example:

> > input1: "blah blah" is 9 Bytes ending without a newline
> > input2: "blah blah\n" is 10 Bytes ending with a newline

> Just call read again. If it returns nil, you reached the end of the
> file. If it returns another line, you didn't.

Thank you for your help but you doesn't get the point here. You can't
decide if a last \n in a file was reached and so read returns 'blah
blah' or the last char in the file is the 'h' so read returns the
identical 'blah blah'. And any further read returns a nil value. So you
aren't able to decide if the file ends with an \n or an other char. Your
suggested function make_readline(handle) doesn't change this.


--
Markus