diff options
author | Andy Wingo <wingo@pobox.com> | 2016-05-13 10:05:23 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2016-05-13 10:05:23 +0200 |
commit | 6ff542ee7138ad6eb837f5a5ac59572a04ef3e45 (patch) | |
tree | 245ff8a6daea0cce08e11b67909da8116d731db9 /libguile/fports.c | |
parent | 704c42870d63eb469c52375575d1a8e3f8eadce3 (diff) | |
download | guile-6ff542ee7138ad6eb837f5a5ac59572a04ef3e45.tar.gz |
Add random_access_p port type method
* doc/ref/api-io.texi (I/O Extensions): Update documentation on
implementing port types. Document get_natural_buffer_sizes. Document
the new random_access_p.
* libguile/fports.c (scm_i_fdes_to_port, fport_random_access_p):
(scm_make_fptob): Instead of frobbing rw_random manually, implement a
random_access_p function.
* libguile/ports.c (default_random_access_p)
(scm_set_port_random_access_p): New functions.
scm_make_port_type, scm_c_make_port_with_encoding): Arrange for
random_access_p to work.
Diffstat (limited to 'libguile/fports.c')
-rw-r--r-- | libguile/fports.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libguile/fports.c b/libguile/fports.c index c6071febb..aab83c9d3 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -418,7 +418,6 @@ scm_i_fdes_to_port (int fdes, long mode_bits, SCM name) port = scm_c_make_port (scm_tc16_fport, mode_bits, (scm_t_bits)fp); - SCM_PTAB_ENTRY (port)->rw_random = SCM_FDES_RANDOM_P (fdes); SCM_SET_FILENAME (port, name); return port; @@ -639,6 +638,12 @@ fport_close (SCM port) scm_syserror ("fport_close"); } +static int +fport_random_access_p (SCM port) +{ + return SCM_FDES_RANDOM_P (SCM_FSTREAM (port)->fdes); +} + /* Query the OS to get the natural buffering for FPORT, if available. */ static void fport_get_natural_buffer_sizes (SCM port, size_t *read_size, size_t *write_size) @@ -663,6 +668,7 @@ scm_make_fptob () scm_set_port_seek (tc, fport_seek); scm_set_port_truncate (tc, fport_truncate); scm_set_port_input_waiting (tc, fport_input_waiting); + scm_set_port_random_access_p (tc, fport_random_access_p); scm_set_port_get_natural_buffer_sizes (tc, fport_get_natural_buffer_sizes); return tc; |