Good!
I found a similar solution. I suggest to return the following instead of
(result? Truth : Ntruth):
But STOP. You have BUFFERED IO!. You should also look into the buffer of
port->storage_as.port.f.
Here is code from the tcl-addinput stuff modified (untested) by me:
#ifdef _STDIO_USES_IOSTREAM /* GNU libc */
# ifdef _IO_STDIO_H
# define READ_DATA_PENDING(fp) (max(0,(fp)->_IO_read_end \
- (fp)->_IO_read_ptr))
#else
# define READ_DATA_PENDING(fp) (max(0,(fp)->_egptr - (fp)->_gptr))
# endif
#endif
#if (!defined (READ_DATA_PENDING)) && defined __SLBF
# define READ_DATA_PENDING(fp) (max(0,fp->_r))
#endif
#if !defined (READ_DATA_PENDING)
# define READ_DATA_PENDING(fp) (fp->_cnt)
#endif
result += READ_DATA_PENDING(port->storage_as.port.f);
return ((result>0)? STk_makeinteger(result) : Ntruth);
Advantage: You know how much You can read and as everything but Ntruth
is suggested as true not too much should be broken.
Fritz
--
Fritz Heinrichmeyer FernUniversitaet Hagen
FAX: +49 2371/566236 LG Elektronische Schaltungen
EMAIL: fritz.heinrichmeyer_at_fernuni-hagen.de Frauenstuhlweg 31
PHONE: +49 02371/566-243 58644 Iserlohn (Germany)
WWW: http://ES-sun2.fernuni-hagen.de
Received on Thu Mar 23 1995 - 09:07:38 CET