diff options
author | Andy Wingo <wingo@pobox.com> | 2014-06-28 15:24:29 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2014-06-29 14:19:00 +0200 |
commit | d40b05386c72c5a17734ee3fd58e35e931ac46ef (patch) | |
tree | bc1b197b299cc4c65d6b177d6d4e1e0f23177fd6 | |
parent | ec412d75627aeffbd816ac351eabcd1b533540c6 (diff) |
Fix bit-count* bug
* libguile/bitvectors.c (scm_bit_count_star): Fix typo introduced in
2005 refactor (!) in which the second arg was erroneously taken from
the first arg.
* test-suite/tests/bitvectors.test: Add test.
* doc/ref/api-compound.texi: Fix doc example for u32vector selector.
-rw-r--r-- | doc/ref/api-compound.texi | 2 | ||||
-rw-r--r-- | libguile/bitvectors.c | 2 | ||||
-rw-r--r-- | test-suite/tests/bitvectors.test | 4 |
3 files changed, 6 insertions, 2 deletions
diff --git a/doc/ref/api-compound.texi b/doc/ref/api-compound.texi index 055de9935..8ec32d687 100644 --- a/doc/ref/api-compound.texi +++ b/doc/ref/api-compound.texi @@ -1142,7 +1142,7 @@ For example, @example (bit-count* #*01110111 #*11001101 #t) @result{} 3 -(bit-count* #*01110111 #u(7 0 4) #f) @result{} 2 +(bit-count* #*01110111 #u32(7 0 4) #f) @result{} 2 @end example @end deffn diff --git a/libguile/bitvectors.c b/libguile/bitvectors.c index 1611119ab..d594317b2 100644 --- a/libguile/bitvectors.c +++ b/libguile/bitvectors.c @@ -720,7 +720,7 @@ SCM_DEFINE (scm_bit_count_star, "bit-count*", 3, 0, 0, ssize_t kv_inc; const scm_t_uint32 *kv_bits; - kv_bits = scm_bitvector_elements (v, &kv_handle, + kv_bits = scm_bitvector_elements (kv, &kv_handle, &kv_off, &kv_len, &kv_inc); if (v_len != kv_len) diff --git a/test-suite/tests/bitvectors.test b/test-suite/tests/bitvectors.test index 8541576aa..d9dfa136d 100644 --- a/test-suite/tests/bitvectors.test +++ b/test-suite/tests/bitvectors.test @@ -70,3 +70,7 @@ (let ((v (bitvector #t #t #f #f))) (bit-set*! v #*101 #f) (equal? v #*0100)))) + +(with-test-prefix "bit-count*" + (pass-if-equal 3 (bit-count* #*01110111 #*11001101 #t)) + (pass-if-equal 2 (bit-count* #*01110111 #u32(7 0 4) #f))) |