lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo wrote:
>
> > /* EOF flag checked here because when lf->f is a terminal, the fread
> >    may return > 0 even when it is set.  If you call fread again and
> >    lf->f is a terminal it will wait for the next line or CTRL-D. */
> 
> Actually I think the exact problem is a little different: fread can
> return > 0  *and* set the EOF flag. The next time getF is called, if
> you call fread, then the terminal will wait for user input. By calling
> feof before fread, you avoid this wait.

How about

	/*
	 * Trying to read past EOF or after an error exposes implemen-
	 * tation and device (file/tty) differences.  Better not ...
	 */
	if (feof(lf->f) || ferror(lf->f))
		return NULL;
?

Ciao, ET.