guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.9-167-g45a28


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.9-167-g45a2851
Date: Tue, 21 Jan 2014 22:43:13 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=45a28515c13348dfd18e53038ad63dd091a5a3c1

The branch, stable-2.0 has been updated
       via  45a28515c13348dfd18e53038ad63dd091a5a3c1 (commit)
      from  a5cbbaa66a2491453db0edff9b0cb592a98f61bf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 45a28515c13348dfd18e53038ad63dd091a5a3c1
Author: Ludovic Courtès <address@hidden>
Date:   Tue Jan 21 23:39:30 2014 +0100

    Buffered custom binary input ports correctly handle partial read requests.
    
    * libguile/r6rs-ports.c (cbip_fill_input): Always initialize 'read_pos'
      when BUFFERED.
    * test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
      input port buffered partial reads"]: New test.

-----------------------------------------------------------------------

Summary of changes:
 libguile/r6rs-ports.c            |    9 ++++++---
 test-suite/tests/r6rs-ports.test |   20 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c
index 30456a8..5f3b156 100644
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@ -406,9 +406,12 @@ cbip_fill_input (SCM port)
        (c_port->read_buf == (unsigned char *) SCM_BYTEVECTOR_CONTENTS (bv));
 
       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.  BV can be passed directly
+            to READ_PROC.  */
+         assert (c_port->read_buf_size == SCM_BYTEVECTOR_LENGTH (bv));
+         c_port->read_pos = (unsigned char *) SCM_BYTEVECTOR_CONTENTS (bv);
+       }
       else
        {
          /* This is an unbuffered port.  When called via the
diff --git a/test-suite/tests/r6rs-ports.test b/test-suite/tests/r6rs-ports.test
index 213c8b7..07c9f44 100644
--- a/test-suite/tests/r6rs-ports.test
+++ b/test-suite/tests/r6rs-ports.test
@@ -22,6 +22,7 @@
   #:use-module (test-suite guile-test)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
+  #:use-module (ice-9 match)
   #:use-module (rnrs io ports)
   #:use-module (rnrs io simple)
   #:use-module (rnrs exceptions)
@@ -456,6 +457,25 @@ not `set-port-position!'"
                          (u8-list->bytevector
                           (map char->integer (string->list "Port!")))))))
 
+  (pass-if-equal "custom binary input port buffered partial reads"
+      "Hello Port!"
+    ;; Check what happens when READ! returns less than COUNT bytes.
+    (let* ((src    (string->utf8 "Hello Port!"))
+           (chunks '(2 4 5))                ; provide 2 bytes, then 4, etc.
+           (offset 0)
+           (read!  (lambda (bv start count)
+                     (match chunks
+                       ((count rest ...)
+                        (bytevector-copy! src offset bv start count)
+                        (set! chunks rest)
+                        (set! offset (+ offset count))
+                        count)
+                       (()
+                        0))))
+           (port   (make-custom-binary-input-port "the port"
+                                                  read! #f #f #f)))
+      (get-string-all port)))
+
   (pass-if-equal "custom binary input port unbuffered & 'port-position'"
       '(0 2 5 11)
     ;; Check that the value returned by 'port-position' is correct, and


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]