From 0de97b83c05a3351c0f09364772391d3108fb61d Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Mon, 18 Oct 1999 20:49:29 +0000 Subject: [PATCH] * fports.c (scm_fdes_to_port): always set rw_random if the fdes is random access. rw_active needs to be maintained even for single directional ports, otherwise scm_seek and probably other things are broken. (thanks to Roland Orre). * strports.c (scm_mkstrport): set rw_random to 1 unconditionally. * ports.c (scm_add_to_port_table): initialise rw_random to 0. * ports.h (scm_port): change the comments on rw_random and rw_active. --- libguile/ChangeLog | 13 +++++++++++++ libguile/fports.c | 3 +-- libguile/ports.c | 1 + libguile/ports.h | 18 +++++++++--------- libguile/strports.c | 4 +--- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index eaa524858..1be7c143b 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,16 @@ +1999-10-18 Gary Houston + + * fports.c (scm_fdes_to_port): always set rw_random if the fdes is + random access. rw_active needs to be maintained even for single + directional ports, otherwise scm_seek and probably other things are + broken. (thanks to Roland Orre). + + * strports.c (scm_mkstrport): set rw_random to 1 unconditionally. + + * ports.c (scm_add_to_port_table): initialise rw_random to 0. + + * ports.h (scm_port): change the comments on rw_random and rw_active. + 1999-10-11 Mikael Djurfeldt * ioext.c: Added #include "feature.h". diff --git a/libguile/fports.c b/libguile/fports.c index 8ea7f7db0..0c0c3c565 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -310,8 +310,7 @@ scm_fdes_to_port (int fdes, char *mode, SCM name) if (fp == NULL) scm_memory_error ("scm_fdes_to_port"); fp->fdes = fdes; - pt->rw_random = (mode_bits & SCM_RDNG) && (mode_bits & SCM_WRTNG) - && SCM_FDES_RANDOM_P (fdes); + pt->rw_random = SCM_FDES_RANDOM_P (fdes); SCM_SETSTREAM (port, fp); if (mode_bits & SCM_BUF0) scm_fport_buffer_add (port, 0, 0); diff --git a/libguile/ports.c b/libguile/ports.c index bb0ae16b3..5ff9cfebf 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -383,6 +383,7 @@ scm_add_to_port_table (SCM port) entry->putback_buf = 0; entry->putback_buf_size = 0; entry->rw_active = SCM_PORT_NEITHER; + entry->rw_random = 0; scm_port_table[scm_port_table_size] = entry; scm_port_table_size++; diff --git a/libguile/ports.h b/libguile/ports.h index 2ce8f4b23..4d9e63f69 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -113,16 +113,16 @@ typedef struct unsigned char shortbuf; /* buffer for "unbuffered" streams. */ - int rw_random; /* true if the port is bidirectional and - random access. implies that the buffers - must be flushed before switching between - reading and writing. */ + int rw_random; /* true if the port is random access. + implies that the buffers must be + flushed before switching between + reading and writing, seeking, etc. */ - enum scm_port_rw_active rw_active; /* for bidirectional random - ports, indicates which of the - buffers is currently in use. can - be SCM_PORT_WRITE, SCM_PORT_READ, - or 0. */ + enum scm_port_rw_active rw_active; /* for random access ports, + indicates which of the buffers + is currently in use. can be + SCM_PORT_WRITE, SCM_PORT_READ, + or SCM_PORT_NEITHER. */ /* a buffer for un-read chars and strings. */ diff --git a/libguile/strports.c b/libguile/strports.c index 3989fb111..5dfa518c5 100644 --- a/libguile/strports.c +++ b/libguile/strports.c @@ -247,9 +247,7 @@ scm_mkstrport (pos, str, modes, caller) pt->write_buf_size = pt->read_buf_size = str_len; pt->write_end = pt->read_end = pt->read_buf + pt->read_buf_size; - /* doesn't check (modes & SCM_RDNG), since the read_buf must be - maintained even for output-only ports. */ - pt->rw_random = modes & SCM_WRTNG; + pt->rw_random = 1; SCM_ALLOW_INTS;