[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 02/07: Port buffer has-eof? field is SCM value
From: |
Andy Wingo |
Subject: |
[Guile-commits] 02/07: Port buffer has-eof? field is SCM value |
Date: |
Thu, 21 Apr 2016 08:28:10 +0000 |
wingo pushed a commit to branch wip-port-refactor
in repository guile.
commit f62974000f74c2e6e160b02137ab037466812014
Author: Andy Wingo <address@hidden>
Date: Sun Apr 17 15:42:13 2016 +0200
Port buffer has-eof? field is SCM value
* libguile/ports.h (scm_t_port_buffer): Rename has_eof member to
has_eof_p, and be a Scheme value, in anticipation of moving the port
buffers to be Scheme objects.
---
libguile/ports.c | 19 ++++++++++---------
libguile/ports.h | 4 ++--
libguile/r6rs-ports.c | 2 +-
3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/libguile/ports.c b/libguile/ports.c
index d1bb231..39551bc 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -307,13 +307,13 @@ scm_set_port_get_natural_buffer_sizes
static void
scm_i_set_pending_eof (SCM port)
{
- SCM_PTAB_ENTRY (port)->read_buf->has_eof = 1;
+ SCM_PTAB_ENTRY (port)->read_buf->has_eof_p = SCM_BOOL_T;
}
static void
scm_i_clear_pending_eof (SCM port)
{
- SCM_PTAB_ENTRY (port)->read_buf->has_eof = 0;
+ SCM_PTAB_ENTRY (port)->read_buf->has_eof_p = SCM_BOOL_F;
}
SCM_DEFINE (scm_i_port_property, "%port-property", 2, 0, 0,
@@ -520,6 +520,7 @@ scm_c_make_port_buffer (size_t size)
ret->size = size;
ret->bytevector = scm_c_make_bytevector (size);
ret->buf = (scm_t_uint8 *) SCM_BYTEVECTOR_CONTENTS (ret->bytevector);
+ ret->has_eof_p = SCM_BOOL_F;
return ret;
}
@@ -1419,7 +1420,7 @@ scm_i_read_unlocked (SCM port, scm_t_port_buffer *buf)
count = scm_i_read_bytes_unlocked (port, buf->bytevector, buf->end,
buf->size - buf->end);
buf->end += count;
- buf->has_eof = count == 0;
+ buf->has_eof_p = scm_from_bool (count == 0);
}
/* Used by an application to read arbitrary number of bytes from an SCM
@@ -1473,7 +1474,7 @@ scm_c_read_bytes_unlocked (SCM port, SCM dst, size_t
start, size_t count)
if (to_copy == 0)
{
/* Consider that we've read off this EOF. */
- read_buf->has_eof = 0;
+ read_buf->has_eof_p = SCM_BOOL_F;
break;
}
dst_ptr += to_copy;
@@ -1537,7 +1538,7 @@ scm_c_read_unlocked (SCM port, void *buffer, size_t size)
else
{
/* Consider that we've read off this EOF. */
- read_buf->has_eof = 0;
+ read_buf->has_eof_p = SCM_BOOL_F;
break;
}
}
@@ -2030,7 +2031,7 @@ scm_i_unget_bytes_unlocked (const scm_t_uint8 *buf,
size_t len, SCM port)
new_buf = scm_c_make_port_buffer (size);
new_buf->end = new_buf->size;
new_buf->cur = new_buf->end - buffered;
- new_buf->has_eof = read_buf->has_eof;
+ new_buf->has_eof_p = read_buf->has_eof_p;
memcpy (new_buf->buf + new_buf->cur, read_buf->buf + read_buf->cur,
buffered);
@@ -2364,7 +2365,7 @@ SCM_DEFINE (scm_setvbuf, "setvbuf", 2, 1, 0,
port);
if (saved_read_buf)
- pt->read_buf->has_eof = saved_read_buf->has_eof;
+ pt->read_buf->has_eof_p = saved_read_buf->has_eof_p;
return SCM_UNSPECIFIED;
}
@@ -2519,7 +2520,7 @@ scm_fill_input_unlocked (SCM port)
scm_t_port *pt = SCM_PTAB_ENTRY (port);
scm_t_port_buffer *read_buf = pt->read_buf;
- if (read_buf->cur < read_buf->end || read_buf->has_eof)
+ if (read_buf->cur < read_buf->end || scm_is_true (read_buf->has_eof_p))
return read_buf;
if (pt->rw_random)
@@ -2800,7 +2801,7 @@ SCM_DEFINE (scm_char_ready_p, "char-ready?", 0, 1, 0,
pt = SCM_PTAB_ENTRY (port);
read_buf = pt->read_buf;
- if (read_buf->cur < read_buf->end || read_buf->has_eof)
+ if (read_buf->cur < read_buf->end || scm_is_true (read_buf->has_eof_p))
/* FIXME: Verify that a whole character is available? */
return SCM_BOOL_T;
else
diff --git a/libguile/ports.h b/libguile/ports.h
index e7277e3..3c48bb7 100644
--- a/libguile/ports.h
+++ b/libguile/ports.h
@@ -85,7 +85,7 @@ typedef struct
zero bytes. Note that in the case of pushback, there could still
be bytes in the buffer, but that after any bytes are read off,
peek-u8 should still return EOF. */
- int has_eof;
+ SCM has_eof_p;
/* Bytevector whose contents are [BUF, BUF + SIZE). */
SCM bytevector;
@@ -441,7 +441,7 @@ scm_get_byte_or_eof_unlocked (SCM port)
/* The next peek or get should cause the read() function to be called
to see if we still have EOF. */
- buf->has_eof = 0;
+ buf->has_eof_p = SCM_BOOL_F;
return EOF;
}
diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c
index 4b2df92..c1cf95a 100644
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@ -477,7 +477,7 @@ SCM_DEFINE (scm_get_bytevector_some, "get-bytevector-some",
1, 0, 0,
buf = scm_fill_input_unlocked (port);
if (buf->cur == buf->end)
{
- buf->has_eof = 0;
+ buf->has_eof_p = SCM_BOOL_F;
return SCM_EOF_VAL;
}
- [Guile-commits] branch wip-port-refactor updated (44b3342 -> 5a342f6), Andy Wingo, 2016/04/21
- [Guile-commits] 02/07: Port buffer has-eof? field is SCM value,
Andy Wingo <=
- [Guile-commits] 06/07: peek-u8 correctness and speed refactor, Andy Wingo, 2016/04/21
- [Guile-commits] 05/07: Port buffer cur/next pointers are Scheme values, Andy Wingo, 2016/04/21
- [Guile-commits] 01/07: Remove unrelated scm_t_port_buffer use in vports, Andy Wingo, 2016/04/21
- [Guile-commits] 04/07: Remove "buf" field from port buffers, Andy Wingo, 2016/04/21
- [Guile-commits] 03/07: Remove size field from port buffers, Andy Wingo, 2016/04/21
- [Guile-commits] 07/07: Port buffers are Scheme values, Andy Wingo, 2016/04/21