From da220f2794a54186721c6ef6ae6a45ba0c3b55a7 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 8 Aug 2002 23:02:28 +0000 Subject: [PATCH] ("scm_new_port_table_entry"): return a boxed SCM in stead of scm_t_port*. The function now takes a tag argument. --- libguile/ChangeLog | 5 +++++ libguile/fports.c | 8 ++++---- libguile/ports.c | 22 +++++++++++----------- libguile/ports.h | 2 +- libguile/strports.c | 10 +++------- libguile/vports.c | 8 +++----- 6 files changed, 27 insertions(+), 28 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 0bb54712e..2e8e6fdd5 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2002-08-09 Han-Wen Nienhuys + + * ports.c ("scm_new_port_table_entry"): return a boxed SCM in + stead of scm_t_port*. The function now takes a tag argument. + 2002-08-08 Han-Wen Nienhuys * gc.h: add scm_debug_cells_gc_interval to public interface diff --git a/libguile/fports.c b/libguile/fports.c index 36ea33115..222b2034d 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -437,10 +437,10 @@ scm_fdes_to_port (int fdes, char *mode, SCM name) } SCM_DEFER_INTS; - pt = scm_new_port_table_entry (); - port = scm_cell (scm_tc16_fport | mode_bits, (scm_t_bits) pt); - pt->port = port; - + + port = scm_new_port_table_entry (scm_tc16_fport); + SCM_SET_CELL_TYPE(port, scm_tc16_fport | mode_bits); + pt = SCM_PTAB_ENTRY(port); { scm_t_fport *fp = (scm_t_fport *) scm_gc_malloc (sizeof (scm_t_fport), "file port"); diff --git a/libguile/ports.c b/libguile/ports.c index b93fa9d8d..80ef93d4e 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -452,10 +452,11 @@ long scm_port_table_size = 0; /* Number of ports in scm_port_table. */ long scm_port_table_room = 20; /* Size of the array. */ -scm_t_port * -scm_new_port_table_entry (void) +SCM +scm_new_port_table_entry (scm_t_bits tag) #define FUNC_NAME "scm_new_port_table_entry" { + SCM z = scm_cell (SCM_EOL, SCM_EOL); scm_t_port *entry = (scm_t_port *) scm_gc_calloc (sizeof (scm_t_port), "port"); if (scm_port_table_size == scm_port_table_room) { @@ -468,17 +469,19 @@ scm_new_port_table_entry (void) scm_port_table_room *= 2; } - entry->port = SCM_EOL; entry->entry = scm_port_table_size; entry->file_name = SCM_BOOL_F; entry->rw_active = SCM_PORT_NEITHER; - scm_port_table[scm_port_table_size] = entry; scm_port_table_size++; - return entry; + entry->port = z; + SCM_SET_CELL_TYPE(z, tag); + SCM_SETPTAB_ENTRY(z, entry); + + return z; } #undef FUNC_NAME @@ -1521,13 +1524,10 @@ scm_void_port (char *mode_str) SCM_DEFER_INTS; { int mode_bits = scm_mode_bits (mode_str); - scm_t_port * pt = scm_new_port_table_entry (); - SCM answer; - + SCM answer = scm_new_port_table_entry (scm_tc16_void_port); + scm_t_port * pt = SCM_PTAB_ENTRY(answer); + scm_port_non_buffer (pt); - answer = scm_cell (scm_tc16_void_port, 0); - SCM_SETPTAB_ENTRY (answer, pt); - pt->port = answer; SCM_SETSTREAM (answer, 0); SCM_SET_CELL_TYPE (answer, scm_tc16_void_port | mode_bits); diff --git a/libguile/ports.h b/libguile/ports.h index 3e7a0dfcb..c85ecfd55 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -257,7 +257,7 @@ SCM_API SCM scm_current_load_port (void); SCM_API SCM scm_set_current_input_port (SCM port); SCM_API SCM scm_set_current_output_port (SCM port); SCM_API SCM scm_set_current_error_port (SCM port); -SCM_API scm_t_port * scm_new_port_table_entry (void); +SCM_API SCM scm_new_port_table_entry (scm_t_bits tag); SCM_API void scm_remove_from_port_table (SCM port); SCM_API void scm_grow_port_cbuf (SCM port, size_t requested); SCM_API SCM scm_pt_size (void); diff --git a/libguile/strports.c b/libguile/strports.c index 94aa928f5..5af68bbcd 100644 --- a/libguile/strports.c +++ b/libguile/strports.c @@ -281,14 +281,10 @@ scm_mkstrport (SCM pos, SCM str, long modes, const char *caller) scm_misc_error ("scm_mkstrport", "port must read or write", SCM_EOL); SCM_DEFER_INTS; - pt = scm_new_port_table_entry (); - z = scm_cell (scm_tc16_strport | modes, 0); - - SCM_SETPTAB_ENTRY (z, pt); - pt->port = z; - - + z = scm_new_port_table_entry (scm_tc16_strport); + pt = SCM_PTAB_ENTRY(z); SCM_SETSTREAM (z, SCM_UNPACK (str)); + SCM_SET_CELL_TYPE(z, scm_tc16_strport|modes); pt->write_buf = pt->read_buf = SCM_STRING_UCHARS (str); pt->read_pos = pt->write_pos = pt->read_buf + SCM_INUM (pos); pt->write_buf_size = pt->read_buf_size = str_len; diff --git a/libguile/vports.c b/libguile/vports.c index 6addd2b0c..977a69e91 100644 --- a/libguile/vports.c +++ b/libguile/vports.c @@ -191,12 +191,10 @@ SCM_DEFINE (scm_make_soft_port, "make-soft-port", 2, 0, 0, SCM_VALIDATE_STRING (2, modes); SCM_DEFER_INTS; - pt = scm_new_port_table_entry (); + z = scm_new_port_table_entry (scm_tc16_sfport); scm_port_non_buffer (pt); - z = scm_cell (scm_tc16_sfport | scm_mode_bits (SCM_STRING_CHARS (modes)), 0); - SCM_SETPTAB_ENTRY (z, pt); - pt->port = z; - + SCM_SET_CELL_TYPE (z, scm_tc16_sfport | scm_mode_bits (SCM_STRING_CHARS (modes))); + SCM_SETSTREAM (z, SCM_UNPACK (pv)); SCM_ALLOW_INTS; return z; -- 2.20.1