1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00

Fix scm_ramapc bugs with 0-inc arrays

* libguile/array-map.c: (scm_ramapc): Cannot flag empty on the product
  inc * dim * dim ... Check every dim.
* test-suite/tests/ramap.test: Tests the 0-inc, non empty case for both
  array-map! and array-copy!.
This commit is contained in:
Daniel Llorens 2013-04-25 18:49:14 +02:00 committed by Andy Wingo
parent 2bd96d9ecd
commit 3ee4c76453
2 changed files with 35 additions and 24 deletions

View file

@ -130,18 +130,19 @@ scm_ramapc (void *cproc_ptr, SCM data, SCM ra0, SCM lra, const char *what)
{
ssize_t inc = SCM_I_ARRAY_DIMS (ra0)[k].inc;
do {
inc *= (UBND (ra0, k) - LBND (ra0, k) + 1);
ssize_t dim = (UBND (ra0, k) - LBND (ra0, k) + 1);
empty = empty || (0 == dim);
inc *= dim;
--k;
} while (k >= 0 && inc == SCM_I_ARRAY_DIMS (ra0)[k].inc);
kroll = k+1;
empty = 0 == inc;
}
else
kroll = 0;
/* Check emptiness of not-unrolled axes. */
for (; k>=0 && !empty; --k)
empty = (0 == (UBND (ra0, k) - LBND (ra0, k) + 1));
for (; k>=0; --k)
empty = empty || (0 == (UBND (ra0, k) - LBND (ra0, k) + 1));
}
else
{