summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2006-11-29 09:05:10 +0000
committerLudovic Courtès <ludo@gnu.org>2006-11-29 09:05:10 +0000
commit22be72d35f90fa94f5dd09444cd891e2bb963cc8 (patch)
tree4cb46402999888e2b74fbe55d63769f6390511e0
parent5b3a39c7ff472eee3978784549a6902c09600810 (diff)
downloadguile-22be72d35f90fa94f5dd09444cd891e2bb963cc8.tar.gz
Changes from arch/CVS synchronization
-rw-r--r--libguile/ChangeLog7
-rw-r--r--libguile/vectors.c12
-rw-r--r--test-suite/ChangeLog6
-rw-r--r--test-suite/tests/vectors.test12
4 files changed, 31 insertions, 6 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index cc567810b..e0a50633e 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,3 +1,10 @@
+2006-11-29 Ludovic Courtès <ludovic.courtes@laas.fr>
+
+ * libguile/vectors.c (scm_vector_to_list): Fixed list
+ construction: elements were not copied when INC is zero (see
+ "shared array" example in `vectors.test'). Reported by
+ Szavai Gyula.
+
2006-11-18 Ludovic Courtès <ludovic.courtes@laas.fr>
* Makefile.am (lib_LTLIBRARIES): Added `libguile-i18n-v-XX.la'.
diff --git a/libguile/vectors.c b/libguile/vectors.c
index 7a6fdfd92..fef48cc3e 100644
--- a/libguile/vectors.c
+++ b/libguile/vectors.c
@@ -392,15 +392,15 @@ SCM_DEFINE (scm_vector_to_list, "vector->list", 1, 0, 0,
SCM res = SCM_EOL;
const SCM *data;
scm_t_array_handle handle;
- size_t i, len;
+ size_t i, count, len;
ssize_t inc;
data = scm_vector_elements (v, &handle, &len, &inc);
- for (i = len*inc; i > 0;)
- {
- i -= inc;
- res = scm_cons (data[i], res);
- }
+ for (i = (len - 1) * inc, count = 0;
+ count < len;
+ i -= inc, count++)
+ res = scm_cons (data[i], res);
+
scm_array_handle_release (&handle);
return res;
}
diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog
index f0384d15a..aad8a1c0e 100644
--- a/test-suite/ChangeLog
+++ b/test-suite/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-29 Ludovic Courtès <ludovic.courtes@laas.fr>
+
+ * test-suite/tests/vectors.test: Use `define-module'.
+ (vector->list): New test prefix. "Shared array" test contributed
+ by Szavai Gyula.
+
2006-11-18 Ludovic Courtès <ludovic.courtes@laas.fr>
* Makefile.am (SCM_TESTS): Added `tests/i18n.test'.
diff --git a/test-suite/tests/vectors.test b/test-suite/tests/vectors.test
index 1fb16bcb0..738a0828a 100644
--- a/test-suite/tests/vectors.test
+++ b/test-suite/tests/vectors.test
@@ -17,6 +17,8 @@
;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;;;; Boston, MA 02110-1301 USA
+(define-module (test-suite vectors)
+ :use-module (test-suite lib))
;; FIXME: As soon as guile supports immutable vectors, this has to be
;; replaced with the appropriate error type and message.
@@ -29,3 +31,13 @@
(expect-fail-exception "vector constant"
exception:immutable-vector
(vector-set! '#(1 2 3) 0 4)))
+
+(with-test-prefix "vector->list"
+
+ (pass-if "simple vector"
+ (equal? '(1 2 3) (vector->list #(1 2 3))))
+
+ (pass-if "shared array"
+ (let ((b (make-shared-array #(1) (lambda (x) '(0)) 2)))
+ (equal? b (list->vector (vector->list b))))))
+