1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 21:40:33 +02:00

* 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.
This commit is contained in:
Gary Houston 1999-10-18 20:49:29 +00:00
parent 4fcd6551ff
commit 0de97b83c0
5 changed files with 25 additions and 14 deletions

View file

@ -1,3 +1,16 @@
1999-10-18 Gary Houston <ghouston@freewire.co.uk>
* 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 <mdj@thalamus.nada.kth.se> 1999-10-11 Mikael Djurfeldt <mdj@thalamus.nada.kth.se>
* ioext.c: Added #include "feature.h". * ioext.c: Added #include "feature.h".

View file

@ -310,8 +310,7 @@ scm_fdes_to_port (int fdes, char *mode, SCM name)
if (fp == NULL) if (fp == NULL)
scm_memory_error ("scm_fdes_to_port"); scm_memory_error ("scm_fdes_to_port");
fp->fdes = fdes; fp->fdes = fdes;
pt->rw_random = (mode_bits & SCM_RDNG) && (mode_bits & SCM_WRTNG) pt->rw_random = SCM_FDES_RANDOM_P (fdes);
&& SCM_FDES_RANDOM_P (fdes);
SCM_SETSTREAM (port, fp); SCM_SETSTREAM (port, fp);
if (mode_bits & SCM_BUF0) if (mode_bits & SCM_BUF0)
scm_fport_buffer_add (port, 0, 0); scm_fport_buffer_add (port, 0, 0);

View file

@ -383,6 +383,7 @@ scm_add_to_port_table (SCM port)
entry->putback_buf = 0; entry->putback_buf = 0;
entry->putback_buf_size = 0; entry->putback_buf_size = 0;
entry->rw_active = SCM_PORT_NEITHER; entry->rw_active = SCM_PORT_NEITHER;
entry->rw_random = 0;
scm_port_table[scm_port_table_size] = entry; scm_port_table[scm_port_table_size] = entry;
scm_port_table_size++; scm_port_table_size++;

View file

@ -113,16 +113,16 @@ typedef struct
unsigned char shortbuf; /* buffer for "unbuffered" streams. */ unsigned char shortbuf; /* buffer for "unbuffered" streams. */
int rw_random; /* true if the port is bidirectional and int rw_random; /* true if the port is random access.
random access. implies that the buffers implies that the buffers must be
must be flushed before switching between flushed before switching between
reading and writing. */ reading and writing, seeking, etc. */
enum scm_port_rw_active rw_active; /* for bidirectional random enum scm_port_rw_active rw_active; /* for random access ports,
ports, indicates which of the indicates which of the buffers
buffers is currently in use. can is currently in use. can be
be SCM_PORT_WRITE, SCM_PORT_READ, SCM_PORT_WRITE, SCM_PORT_READ,
or 0. */ or SCM_PORT_NEITHER. */
/* a buffer for un-read chars and strings. */ /* a buffer for un-read chars and strings. */

View file

@ -247,9 +247,7 @@ scm_mkstrport (pos, str, modes, caller)
pt->write_buf_size = pt->read_buf_size = str_len; pt->write_buf_size = pt->read_buf_size = str_len;
pt->write_end = pt->read_end = pt->read_buf + pt->read_buf_size; 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 pt->rw_random = 1;
maintained even for output-only ports. */
pt->rw_random = modes & SCM_WRTNG;
SCM_ALLOW_INTS; SCM_ALLOW_INTS;