summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@lilypond.org>2002-08-08 23:02:28 +0000
committerHan-Wen Nienhuys <hanwen@lilypond.org>2002-08-08 23:02:28 +0000
commitda220f2794a54186721c6ef6ae6a45ba0c3b55a7 (patch)
treed332465e3de0f761b8a575dae437aac5b5102116
parent395b0a341fff3630fffe7d42bf2c570faeeb68e8 (diff)
downloadguile-da220f2794a54186721c6ef6ae6a45ba0c3b55a7.tar.gz
("scm_new_port_table_entry"): return a boxed SCM in
stead of scm_t_port*. The function now takes a tag argument.
-rw-r--r--libguile/ChangeLog5
-rw-r--r--libguile/fports.c8
-rw-r--r--libguile/ports.c22
-rw-r--r--libguile/ports.h2
-rw-r--r--libguile/strports.c10
-rw-r--r--libguile/vports.c8
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 <hanwen@cs.uu.nl>
+
+ * 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 <hanwen@cs.uu.nl>
* 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;