This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
scm_port.stream
- To: Guile Mailing List <guile at sourceware dot cygnus dot com>, Gary Houston <ghouston at arglist dot com>
- Subject: scm_port.stream
- From: Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>
- Date: Thu, 30 Mar 2000 11:45:11 +0200 (MEST)
Hello.
In ports.h, the member stream of struct scm_port is of type SCM. However,
this variable may contain raw C data. Thus, I suggest to change the type
to scm_bits_t.
Below are the suggested patches. Gary, could you please send me a
confirmation if they are OK?
Best regards
Dirk Herrmann
diff -u -r1.58 ports.h
--- ports.h 2000/03/30 09:15:15 1.58
+++ ports.h 2000/03/30 09:31:17
@@ -74,9 +74,8 @@
int revealed; /* 0 not revealed, > 1 revealed.
* Revealed ports do not get GC'd.
*/
- /* data for the underlying port implementation. may be an SCM cell or
- cast to a pointer to C data. */
- SCM stream;
+ /* data for the underlying port implementation as a raw C value. */
+ scm_bits_t stream;
SCM file_name; /* debugging support. */
int line_number; /* debugging support. */
@@ -165,7 +164,7 @@
#define SCM_PTAB_ENTRY(x) ((scm_port *) SCM_CELL_WORD_1 (x))
#define SCM_SETPTAB_ENTRY(x,ent) (SCM_SET_CELL_WORD_1 ((x), (ent)))
#define SCM_STREAM(x) (SCM_PTAB_ENTRY(x)->stream)
-#define SCM_SETSTREAM(x,s) (SCM_PTAB_ENTRY(x)->stream = (SCM) (s))
+#define SCM_SETSTREAM(x,s) (SCM_PTAB_ENTRY(x)->stream = ((scm_bits_t) (s)))
#define SCM_FILENAME(x) (SCM_PTAB_ENTRY(x)->file_name)
#define SCM_LINUM(x) (SCM_PTAB_ENTRY(x)->line_number)
#define SCM_COL(x) (SCM_PTAB_ENTRY(x)->column_number)
diff -u -r1.53 strports.c
--- strports.c 2000/03/19 19:01:14 1.53
+++ strports.c 2000/03/30 09:31:17
@@ -95,15 +95,17 @@
static void
st_resize_port (scm_port *pt, off_t new_size)
{
+ SCM stream = SCM_PACK (pt->stream);
+
off_t index = pt->write_pos - pt->write_buf;
pt->write_buf_size = new_size;
- scm_vector_set_length_x (pt->stream, SCM_MAKINUM (new_size));
+ scm_vector_set_length_x (stream, SCM_MAKINUM (new_size));
/* reset buffer in case reallocation moved the string. */
{
- pt->read_buf = pt->write_buf = SCM_CHARS (pt->stream);
+ pt->read_buf = pt->write_buf = SCM_CHARS (stream);
pt->read_pos = pt->write_pos = pt->write_buf + index;
pt->write_end = pt->write_buf + pt->write_buf_size;
pt->read_end = pt->read_buf + pt->read_buf_size;
@@ -273,7 +275,7 @@
pt = scm_add_to_port_table (z);
SCM_SETCAR (z, scm_tc16_strport | modes);
SCM_SETPTAB_ENTRY (z, pt);
- SCM_SETSTREAM (z, str);
+ SCM_SETSTREAM (z, SCM_UNPACK (str));
pt->write_buf = pt->read_buf = SCM_ROCHARS (str);
pt->read_pos = pt->write_pos = pt->read_buf + SCM_INUM (pos);
pt->write_buf_size = pt->read_buf_size = str_len;
diff -u -r1.33 vports.c
--- vports.c 2000/03/19 19:01:16 1.33
+++ vports.c 2000/03/30 09:31:17
@@ -71,7 +71,7 @@
sf_flush (SCM port)
{
scm_port *pt = SCM_PTAB_ENTRY (port);
- SCM stream = pt->stream;
+ SCM stream = SCM_PACK (pt->stream);
if (pt->write_pos > pt->write_buf)
{
@@ -190,7 +190,7 @@
scm_port_non_buffer (pt);
SCM_SETCAR (z, scm_tc16_sfport | scm_mode_bits (SCM_ROCHARS (modes)));
SCM_SETPTAB_ENTRY (z, pt);
- SCM_SETSTREAM (z, pv);
+ SCM_SETSTREAM (z, SCM_UNPACK (pv));
SCM_ALLOW_INTS;
return z;
}