bytevectors: Add support for `equal?'.
authorLudovic Courtès <ludo@gnu.org>
Sun, 21 Jun 2009 14:10:02 +0000 (21 16:10 +0200)
committerLudovic Courtès <ludo@gnu.org>
Sun, 21 Jun 2009 14:13:01 +0000 (21 16:13 +0200)
Patch from Guile `master' by me.

src/bytevector.c
tests/bytevector.test

index b8aab3a..5bc44c9 100644 (file)
@@ -295,6 +295,11 @@ SCM_SMOB_PRINT (scm_tc16_r6rs_bytevector, print_bytevector,
   return 1;
 }
 
+SCM_SMOB_EQUALP (scm_tc16_r6rs_bytevector, bytevector_equal_p, bv1, bv2)
+{
+  return scm_r6rs_bytevector_eq_p (bv1, bv2);
+}
+
 SCM_SMOB_FREE (scm_tc16_r6rs_bytevector, free_bytevector, bv)
 {
 
index ebe6136..fc539b3 100644 (file)
       (bytevector-sint-set! b 0 -16 (endianness big) 2)
       (bytevector-sint-set! b 1 -16 (endianness little) 2)
       (equal? (bytevector->u8-list b)
-             '(#xff #xf0 #xff)))))
+             '(#xff #xf0 #xff))))
+
+  (pass-if "equal?"
+    (let ((bv1 (u8-list->bytevector (iota 123)))
+          (bv2 (u8-list->bytevector (iota 123))))
+      (equal? bv1 bv2))))
 
 \f
 (with-test-prefix "2.4 Operations on Integers of Arbitrary Size"