summaryrefslogtreecommitdiff
path: root/libguile/r6rs-ports.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2015-01-22 14:53:06 +0100
committerAndy Wingo <wingo@pobox.com>2015-01-22 14:53:06 +0100
commit0a5b437ef9063df2a3728338a7cd6b86c4c2e275 (patch)
treeb06a513c6dd1fef8644e8a2d6813bd2ca4252c17 /libguile/r6rs-ports.c
parente19235e21bad6fdf8c8152dc5b460685b551f330 (diff)
parented72201a795ac1c8d6c0288b6bb710f2bd0ebd9c (diff)
Merge commit 'ed72201a795ac1c8d6c0288b6bb710f2bd0ebd9c'
Conflicts: test-suite/tests/r6rs-ports.test
Diffstat (limited to 'libguile/r6rs-ports.c')
-rw-r--r--libguile/r6rs-ports.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c
index 1b0aba406..2c2b657d7 100644
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc.
+/* Copyright (C) 2009, 2010, 2011, 2013-2015 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -299,9 +299,10 @@ cbip_setvbuf (SCM port, long read_size, long write_size)
switch (read_size)
{
case 0:
- /* Unbuffered: keep PORT's bytevector as is (it will be used in
- future 'scm_c_read' calls), but point to the one-byte buffer. */
- pt->read_buf = &pt->shortbuf;
+ /* Unbuffered: keep using PORT's bytevector as the underlying
+ buffer (it will also be used by future 'scm_c_read' calls.) */
+ assert (SCM_BYTEVECTOR_LENGTH (bv) >= 1);
+ pt->read_buf = (unsigned char *) SCM_BYTEVECTOR_CONTENTS (bv);
pt->read_buf_size = 1;
break;
@@ -385,9 +386,11 @@ cbip_fill_input (SCM port)
if (buffered)
{
- /* Make sure the buffer isn't corrupt. BV can be passed directly
- to READ_PROC. */
- assert (c_port->read_buf_size == SCM_BYTEVECTOR_LENGTH (bv));
+ /* Make sure the buffer isn't corrupt. Its size can be 1 when
+ someone called 'setvbuf' with _IONBF. BV can be passed
+ directly to READ_PROC. */
+ assert (c_port->read_buf_size == SCM_BYTEVECTOR_LENGTH (bv)
+ || c_port->read_buf_size == 1);
c_port->read_pos = (unsigned char *) SCM_BYTEVECTOR_CONTENTS (bv);
}
else