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

mint library fgetc



I have been playing around with Scheme->C under MiNT, trying
to track down why it doesn't work the same as under UNIX on
the Sun.  If anybody has ported Scheme->C to MiNT, could you
let me know.

My first problem is in the interpretation of ^D (EOF). S2C has the
following code for reading characters.  On the Sun, ^D on a tty causes
getc to return EOF, and feof() to return TRUE, so EOFOBJECT is
returned.  Under MiNT, ^D on the console returns EOF, but feof()
returns FALSE.

Scheme->C code for getc:

	character = getc( stream );
	if  (character == EOF)   {
	   if  (feof( stream ))  {
	      clearerr( stream );
	      return( EOFOBJECT );
	   }
	   else  
	      return( CSTRING_TSCP( strerror( ferror( stream ) ) ) );
	}
	return( C_CHAR( character ) );

Below is part of the code for filbuf in the MiNT library.  It looks
like the EOF flag is not set if the file has the IODEV flag set.  I
don't think this code should care what kind of device it is reading
from.  What do you think?

MiNT filbuf code:

    fp->_ptr = fp->_base;
    if((got = _read(fp->_file, fp->_base, (unsigned long)fp->_bsiz)) <= 0)
    {   /* EOF or error */
	fp->_flag |= ((got == 0) ? ((f & _IODEV) ? 0 : _IOEOF) : _IOERR);
	fp->_cnt = 0;
	return EOF;
    }
    fp->_cnt = got - 1;
    return *(fp->_ptr)++;


Brad