scm_evict_ports, scm_open_file, scm_stdio_to_port): Get rid of
SCM_P macro.
Do magic to mix reads and writes on stdio FILE-based ports.
* fports.c (FPORT_READ_SAFE, FPORT_WRITE_SAFE, FPORT_ALL_OKAY):
New macros.
(pre_read, pre_write): New functions.
(local_fgetc, local_fgets, local_ffwrite, local_fputc,
local_fputs): Call them.
(local_fflush): Mark the port as ready for reading and writing.
(scm_stdio_to_port): Set the FPORT_READ_SAFE, FPORT_WRITE_SAFE
flags on new port objects. This might not be accurate --- who
knows what state the FILE * is in when we get it --- but it won't
do extraneous calls to fflush or fseek, so it's no worse than the
behavior before this change.
* ports.h: Add comment.
Centralize the creation of port objects based on stdio FILE * in
fports.c; don't just throw them together anywhere.
* fports.c (scm_stdio_to_port): Make NAME a SCM value, which is
what the rest of Guile wants. Don't set the revealed count;
that's only appropriate for stdin, stdout, stderr.
(scm_standard_stream_to_port): This function does set the revealed
count.
* init.c (scm_init_standard_ports): Use scm_standard_stream_to_port,
not scm_stdio_to_port.
* filesys.c (scm_open): Call scm_stdio_to_port; don't write it out.
* fports.c (scm_open_file): Same.
* posix.c (scm_pipe): Same.
* socket.c (scm_sock_fd_to_port): Same.
* ioext.c (scm_fdopen): Same.
(scm_freopen): Moved from here to...
* fports.c (scm_freopen): ... here. This is really something that
munges the internals of an fport, so it should go here.
* fports.h (scm_stdio_to_port): Adjust prototype.
(scm_standard_stream_to_port, scm_freopen): New protoypes.
* ioext.h (scm_freopen): Prototype removed.
/* PORT FLAGS
* A set of flags characterizes a port.
+ * Note that we reserve the bits 1 << 24 and above for use by the
+ * routines in the port's scm_ptobfuns structure.
*/
#define SCM_OPN (1L<<16) /* Is the port open? */
#define SCM_RDNG (2L<<16) /* Is it a readable port? */