lua-users home
lua-l archive

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


It was thus said that the Great Paul K once stated:
> Hi Dirk,
> 
> > Or alternatively, is there a way to unread a line when you realize
> > it's not meant for the current group?
> 
> You can use fh:seek() to get the position before reading and then set
> to that position after reading, so the next reading operation starts
> there.

  That only works if what you are reading from *is* a file.  Anything else
(io.stdin, a network connection, etc.) won't work as you cannot seek on
those types of devices.

  Buffering a line works for both seekable and non-seekable data sources.

  -spc (There is ungetc() in C, but you are only guarenteed one character of
	pushback ... )