summaryrefslogtreecommitdiff
path: root/libguile/array-map.c
diff options
context:
space:
mode:
authorDaniel Llorens <daniel.llorens@bluewin.ch>2017-02-13 13:49:35 +0100
committerDaniel Llorens <daniel.llorens@bluewin.ch>2017-10-31 13:23:17 +0100
commitf52fc0566feabe4f1d3ba630287a418606ac30f9 (patch)
tree3f96b38a8d2c02c798bd404c240bd0010018864e /libguile/array-map.c
parent3bfd4aaa6e080dc5b33875921b74d733ac16feb2 (diff)
downloadguile-f52fc0566feabe4f1d3ba630287a418606ac30f9.tar.gz
Support non-zero lower bounds in array-slice-for-each
* libguile/array-handle.c (scm_array_handle_writable_elements): Fix error message. * libguile/array-map.c (scm_array_slice_for_each): Support non-zero lower bounds. Fix error messages. * test-suite/tests/array-map.test: Test scm_array_slice_for_each with non-zero lower bound argument.
Diffstat (limited to 'libguile/array-map.c')
-rw-r--r--libguile/array-map.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/libguile/array-map.c b/libguile/array-map.c
index 651a1bfb9..29e4aa785 100644
--- a/libguile/array-map.c
+++ b/libguile/array-map.c
@@ -679,6 +679,7 @@ SCM_DEFINE (scm_array_slice_for_each, "array-slice-for-each", 2, 0, 1,
"@end lisp")
#define FUNC_NAME s_scm_array_slice_for_each
{
+ SCM xargs = args;
int const N = scm_ilength (args);
int const frank = scm_to_int (frame_rank);
int ocd;
@@ -742,9 +743,9 @@ SCM_DEFINE (scm_array_slice_for_each, "array-slice-for-each", 2, 0, 1,
assert((pool0+pool_size==pool) && "internal error");
#undef AFIC_ALLOC_ADVANCE
- for (n=0; scm_is_pair(args); args=scm_cdr(args), ++n)
+ for (n=0, xargs=args; scm_is_pair(xargs); xargs=scm_cdr(xargs), ++n)
{
- args_[n] = scm_car(args);
+ args_[n] = scm_car(xargs);
scm_array_get_handle(args_[n], ah+n);
as[n] = scm_array_handle_dims(ah+n);
rank[n] = scm_array_handle_rank(ah+n);
@@ -752,29 +753,24 @@ SCM_DEFINE (scm_array_slice_for_each, "array-slice-for-each", 2, 0, 1,
/* checks */
msg = NULL;
if (frank<0)
- msg = "bad frame rank";
+ msg = "bad frame rank ~S, ~S";
else
{
for (n=0; n!=N; ++n)
{
if (rank[n]<frank)
{
- msg = "frame too large for arguments";
+ msg = "frame too large for arguments: ~S, ~S";
goto check_msg;
}
for (k=0; k!=frank; ++k)
{
- if (as[n][k].lbnd!=0)
+ if (as[0][k].lbnd!=as[n][k].lbnd || as[0][k].ubnd!=as[n][k].ubnd)
{
- msg = "non-zero base index is not supported";
+ msg = "mismatched frames: ~S, ~S";
goto check_msg;
}
- if (as[0][k].ubnd!=as[n][k].ubnd)
- {
- msg = "mismatched frames";
- goto check_msg;
- }
- s[k] = as[n][k].ubnd + 1;
+ s[k] = as[n][k].ubnd - as[n][k].lbnd + 1;
/* this check is needed if the array cannot be entirely */
/* unrolled, because the unrolled subloop will be run before */
@@ -789,7 +785,7 @@ SCM_DEFINE (scm_array_slice_for_each, "array-slice-for-each", 2, 0, 1,
{
for (n=0; n!=N; ++n)
scm_array_handle_release(ah+n);
- scm_misc_error("array-slice-for-each", msg, scm_cons_star(frame_rank, args));
+ scm_misc_error("array-slice-for-each", msg, scm_cons(frame_rank, args));
}
/* prepare moving cells. */
for (n=0; n!=N; ++n)