unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH 1/2] Add tests for get-bytevector-some!
@ 2021-01-22 10:10 Andrew Whatson
  2021-01-22 10:10 ` [PATCH 2/2] Fix suspendable implementation of 'get-bytevector-some!' Andrew Whatson
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Whatson @ 2021-01-22 10:10 UTC (permalink / raw)
  To: guile-devel; +Cc: Andrew Whatson

* test-suite/tests/r6rs-ports.test (get-bytevector-n! [short]): add
  (get-bytevector-n! [long]): add
---
 test-suite/tests/r6rs-ports.test | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/test-suite/tests/r6rs-ports.test b/test-suite/tests/r6rs-ports.test
index 4d1981df2..c42783465 100644
--- a/test-suite/tests/r6rs-ports.test
+++ b/test-suite/tests/r6rs-ports.test
@@ -23,6 +23,7 @@
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
   #:use-module (ice-9 match)
+  #:use-module ((ice-9 binary-ports) #:select (get-bytevector-some!))
   #:use-module (rnrs io ports)
   #:use-module (rnrs io simple)
   #:use-module (rnrs exceptions)
@@ -183,6 +184,25 @@
            (equal? (bytevector->u8-list bv)
                    (map char->integer (string->list str))))))
 
+  (pass-if "get-bytevector-some! [short]"
+    (let* ((port (open-input-string "GNU Guile"))
+           (bv   (make-bytevector 4))
+           (read (get-bytevector-some! port bv 0 4)))
+      (and (equal? read 4)
+           (equal? (bytevector->u8-list bv)
+                   (map char->integer (string->list "GNU "))))))
+
+  (pass-if "get-bytevector-some! [long]"
+    (let* ((str  "GNU Guile")
+           (port (open-input-string str))
+           (bv   (make-bytevector 256))
+           (read (get-bytevector-some! port bv 0 256)))
+      (and (equal? read (string-length str))
+           (equal? (map (lambda (i)
+                          (bytevector-u8-ref bv i))
+                        (iota read))
+                   (map char->integer (string->list str))))))
+
   (pass-if "get-bytevector-all"
     (let* ((str   "GNU Guile")
            (index 0)
-- 
2.30.0




^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] Fix suspendable implementation of 'get-bytevector-some!'
  2021-01-22 10:10 [PATCH 1/2] Add tests for get-bytevector-some! Andrew Whatson
@ 2021-01-22 10:10 ` Andrew Whatson
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Whatson @ 2021-01-22 10:10 UTC (permalink / raw)
  To: guile-devel; +Cc: Andrew Whatson

* module/ice-9/suspendable-ports.scm (get-bytevector-some!): Fix
  incorrect arguments to bytevector-copy!
---
 module/ice-9/suspendable-ports.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/module/ice-9/suspendable-ports.scm b/module/ice-9/suspendable-ports.scm
index f5f005cca..a823f1d37 100644
--- a/module/ice-9/suspendable-ports.scm
+++ b/module/ice-9/suspendable-ports.scm
@@ -338,7 +338,7 @@
                 the-eof-object)
               (let ((transfer-size (min count buffered)))
                 (bytevector-copy! (port-buffer-bytevector buf) cur
-                                  transfer-size start buffered)
+                                  bv start transfer-size)
                 (set-port-buffer-cur! buf (+ cur transfer-size))
                 transfer-size))))))
 
-- 
2.30.0




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-22 10:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 10:10 [PATCH 1/2] Add tests for get-bytevector-some! Andrew Whatson
2021-01-22 10:10 ` [PATCH 2/2] Fix suspendable implementation of 'get-bytevector-some!' Andrew Whatson

unofficial mirror of guile-devel@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-devel/0 guile-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-devel guile-devel/ https://yhetil.org/guile-devel \
		guile-devel@gnu.org
	public-inbox-index guile-devel

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.devel
	nntp://news.gmane.io/gmane.lisp.guile.devel


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git