wingo pushed a commit to branch master in repository guile. commit f46cb25a17fd9b014e2d7ad0b2d27c5dd94688cd Author: Andy Wingo <wi...@pobox.com> Date: Wed Aug 31 15:42:51 2016 +0200
Set rw_random correctly for all custom binary port types * libguile/r6rs-ports.c (custom_binary_port_random_access_p): Rename from custom_binary_input_output_port_type, and use for all custom binary port types. --- libguile/r6rs-ports.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c index b52eb85..674d89a 100644 --- a/libguile/r6rs-ports.c +++ b/libguile/r6rs-ports.c @@ -193,6 +193,14 @@ struct custom_binary_port { SCM close; }; +static int +custom_binary_port_random_access_p (SCM port) +{ + struct custom_binary_port *stream = (void *) SCM_STREAM (port); + + return scm_is_true (stream->set_position_x); +} + static scm_t_off custom_binary_port_seek (SCM port, scm_t_off offset, int whence) #define FUNC_NAME "custom_binary_port_seek" @@ -336,6 +344,8 @@ initialize_custom_binary_input_ports (void) custom_binary_input_port_read, NULL); scm_set_port_seek (custom_binary_input_port_type, custom_binary_port_seek); + scm_set_port_random_access_p (custom_binary_input_port_type, + custom_binary_port_random_access_p); scm_set_port_close (custom_binary_input_port_type, custom_binary_port_close); } @@ -942,6 +952,8 @@ initialize_custom_binary_output_ports (void) NULL, custom_binary_output_port_write); scm_set_port_seek (custom_binary_output_port_type, custom_binary_port_seek); + scm_set_port_random_access_p (custom_binary_output_port_type, + custom_binary_port_random_access_p); scm_set_port_close (custom_binary_output_port_type, custom_binary_port_close); } @@ -1004,15 +1016,6 @@ SCM_DEFINE (scm_make_custom_binary_input_output_port, #undef FUNC_NAME -static int -custom_binary_input_output_port_random_access_p (SCM port) -{ - struct custom_binary_port *stream = (void *) SCM_STREAM (port); - - return scm_is_true (stream->set_position_x); -} - - /* Instantiate the custom binary input_output port type. */ static inline void initialize_custom_binary_input_output_ports (void) @@ -1025,7 +1028,7 @@ initialize_custom_binary_input_output_ports (void) scm_set_port_seek (custom_binary_input_output_port_type, custom_binary_port_seek); scm_set_port_random_access_p (custom_binary_input_output_port_type, - custom_binary_input_output_port_random_access_p); + custom_binary_port_random_access_p); scm_set_port_close (custom_binary_input_output_port_type, custom_binary_port_close); }