summaryrefslogtreecommitdiff
path: root/libguile/read.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2016-04-04 11:03:52 +0200
committerAndy Wingo <wingo@pobox.com>2016-04-04 16:30:57 +0200
commit2caae477c55ed945555715150606a097d8b50f9b (patch)
tree457f4251155af83b9a2908248f52dfd2c2e7092b /libguile/read.c
parentb538a96f927d5a0079655bd6df8f019c008930ee (diff)
Refactor to rw_random / rw_active port flags
* libguile/fports.c (fport_flush, fport_end_input): Move rw_active handling to ports.c. * libguile/ioext.c (scm_redirect_port): Use scm_flush_unlocked instead of calling the flush function directly. * libguile/ports.c (scm_c_make_port_with_encoding): Ports default to "rw_random" mode when they have a seek function. (scm_c_read_unlocked, scm_i_unget_bytes_unlocked) (scm_slow_get_byte_or_eof_unlocked) (scm_slow_peek_byte_or_eof_unlocked): Flush write buffer and set rw_active always in the same way, and only if rw_random is true. (scm_end_input_unlocked, scm_flush_unlocked): Clear rw_active here unconditionally. (scm_c_write_unlocked): Flush read buffer and set rw_active always in the same way, but only if rw_random is true. (scm_c_write, scm_lfwrite): Whitespace fixes. (scm_lfwrite_substr): Don't flush read buffer; lower-level code will do this. (scm_truncate_file): Use scm_flush_unlocked instead of calling the flush function directly. * libguile/r6rs-ports.c (transcoded_port_flush): Don't muck with rw_active. * libguile/read.c (scm_i_scan_for_encoding): Flush write buffer if needed in same way as ports.c. * libguile/strports.c (st_end_input): Don't muck with rw_active. (scm_mkstrport): rw_random defaults to 1 now.
Diffstat (limited to 'libguile/read.c')
-rw-r--r--libguile/read.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libguile/read.c b/libguile/read.c
index ecf27ff6e..346bcc969 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -2065,11 +2065,12 @@ scm_i_scan_for_encoding (SCM port)
pt = SCM_PTAB_ENTRY (port);
- if (pt->rw_active == SCM_PORT_WRITE)
- scm_flush_unlocked (port);
-
if (pt->rw_random)
- pt->rw_active = SCM_PORT_READ;
+ {
+ if (pt->rw_active == SCM_PORT_WRITE)
+ scm_flush_unlocked (port);
+ pt->rw_active = SCM_PORT_READ;
+ }
if (pt->read_pos == pt->read_end)
{