Mark H Weaver writes: > Andy Wingo writes: >> Maybe if it is somehow confined to scm_peek_char and scm_fill_input it >> could be doable. > > I think I now see a reasonable way to fix this. > > First of all, all interfaces that do something like 'peek' would, when > returning an EOF, set a 'pending_eof' flag in the port structure. Then > 'scm_fill_input' would start by checking this flag; if it is set, then > it would clear the flag and return EOF. > > We would also need to clear the 'pending_eof' flag in a few other > places, most notably in 'scm_end_input'. In theory, that might be > enough, but to be on the safe side we should also clear the flag in any > procedure that writes or seeks. Upon further thought, I decided that we shouldn't clear it on writes. If 'rw_random' is set, then 'scm_end_input' will be called anyway. If 'rw_random' is not set, then we should *not* clear the flag on writes, because it indicates that the read and write streams are independent, e.g. a terminal or socket. On the other hand, the 'pending_eof' flag should of course be cleared when putting characters back (unget). I've attached a proposed patch. It depends on the three preliminary patches posted here: http://lists.gnu.org/archive/html/guile-devel/2013-03/msg00221.html Thoughts? Regards, Mark