diff options
author | Daniel Llorens <daniel.llorens@bluewin.ch> | 2013-04-20 01:27:42 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2014-01-27 21:48:02 +0100 |
commit | b713626073eba62ef233bcff21812efe64350a25 (patch) | |
tree | 161fa9dfec5a4d6374c1bb689c5b703968439d5a /libguile | |
parent | d4f63dacdd9f3f7c41217988c084ce6ca6432d9f (diff) | |
download | guile-b713626073eba62ef233bcff21812efe64350a25.tar.gz |
Fix compilation errors when reading arrays at the repl
* compile-assembly.scm
- vector-fold2: handle rank 1 arrays, since this is called with
the result of array-contents which need not be a vector.
- dump-constants: fix uses of vector-fold2. Replace vector-length
on result of array-contents by array-length.
* libguile/arrays.c
- scm_array_contents: branch cases not on scm_is_generalized_vector but
on SCM_I_ARRAYP. Thus lbnd!=0, which could happen with
scm_is_generalized_vector, never appears in the output.
* test-suite/tests/arrays.test
- tests for array-contents.
Diffstat (limited to 'libguile')
-rw-r--r-- | libguile/arrays.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/libguile/arrays.c b/libguile/arrays.c index a743cfe8c..e86a620ae 100644 --- a/libguile/arrays.c +++ b/libguile/arrays.c @@ -562,15 +562,13 @@ SCM_DEFINE (scm_array_contents, "array-contents", 1, 1, 0, "contiguous in memory.") #define FUNC_NAME s_scm_array_contents { - SCM sra; - - if (scm_is_generalized_vector (ra)) - return ra; - - if (SCM_I_ARRAYP (ra)) + if (!scm_is_array (ra)) + scm_wrong_type_arg_msg (NULL, 0, ra, "array"); + else if (SCM_I_ARRAYP (ra)) { + SCM v; size_t k, ndim = SCM_I_ARRAY_NDIM (ra), len = 1; - if (!SCM_I_ARRAYP (ra) || !SCM_I_ARRAY_CONTP (ra)) + if (!SCM_I_ARRAY_CONTP (ra)) return SCM_BOOL_F; for (k = 0; k < ndim; k++) len *= SCM_I_ARRAY_DIMS (ra)[k].ubnd - SCM_I_ARRAY_DIMS (ra)[k].lbnd + 1; @@ -587,23 +585,23 @@ SCM_DEFINE (scm_array_contents, "array-contents", 1, 1, 0, } } - { - SCM v = SCM_I_ARRAY_V (ra); - size_t length = scm_c_array_length (v); - if ((len == length) && 0 == SCM_I_ARRAY_BASE (ra) && SCM_I_ARRAY_DIMS (ra)->inc) - return v; - } - - sra = scm_i_make_array (1); - SCM_I_ARRAY_DIMS (sra)->lbnd = 0; - SCM_I_ARRAY_DIMS (sra)->ubnd = len - 1; - SCM_I_ARRAY_V (sra) = SCM_I_ARRAY_V (ra); - SCM_I_ARRAY_BASE (sra) = SCM_I_ARRAY_BASE (ra); - SCM_I_ARRAY_DIMS (sra)->inc = (ndim ? SCM_I_ARRAY_DIMS (ra)[ndim - 1].inc : 1); - return sra; + v = SCM_I_ARRAY_V (ra); + if ((len == scm_c_array_length (v)) && (0 == SCM_I_ARRAY_BASE (ra)) + && SCM_I_ARRAY_DIMS (ra)->inc) + return v; + else + { + SCM sra = scm_i_make_array (1); + SCM_I_ARRAY_DIMS (sra)->lbnd = 0; + SCM_I_ARRAY_DIMS (sra)->ubnd = len - 1; + SCM_I_ARRAY_V (sra) = v; + SCM_I_ARRAY_BASE (sra) = SCM_I_ARRAY_BASE (ra); + SCM_I_ARRAY_DIMS (sra)->inc = (ndim ? SCM_I_ARRAY_DIMS (ra)[ndim - 1].inc : 1); + return sra; + } } else - scm_wrong_type_arg_msg (NULL, 0, ra, "array"); + return ra; } #undef FUNC_NAME |