mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-02 23:50:47 +02:00
Fix bad uses of base and lbnd on rank 1 arrays
* libguile/array-map.c - rafill, ramap, rafe, racp: object from SCM_I_ARRAY_V always has base 0, lbnd 0 and inc 1; make use of this. * libguile/arrays.c - array_handle_ref, array_handle_set: idem. - array_get_handle: sanity check. * libguile/generalized-vectors.c - scm_c_generalized_vector_ref, scm_c_generalized_vector_set_x: pos should be base when idx is lbnd. Furthermore, pos should be signed and have its overflow checked; do this by handling the job to scm_c_array_ref_1, scm_c_array_set_1_x. * libguile/generalized-vectors.h - fix prototypes.
This commit is contained in:
parent
499a9804c7
commit
943f690a30
4 changed files with 25 additions and 34 deletions
|
@ -824,7 +824,6 @@ array_handle_ref (scm_t_array_handle *hh, size_t pos)
|
|||
scm_t_array_handle h;
|
||||
SCM ret;
|
||||
scm_array_get_handle (SCM_I_ARRAY_V (hh->array), &h);
|
||||
pos = h.base + h.dims[0].lbnd + pos * h.dims[0].inc;
|
||||
ret = h.impl->vref (&h, pos);
|
||||
scm_array_handle_release (&h);
|
||||
return ret;
|
||||
|
@ -835,7 +834,6 @@ array_handle_set (scm_t_array_handle *hh, size_t pos, SCM val)
|
|||
{
|
||||
scm_t_array_handle h;
|
||||
scm_array_get_handle (SCM_I_ARRAY_V (hh->array), &h);
|
||||
pos = h.base + h.dims[0].lbnd + pos * h.dims[0].inc;
|
||||
h.impl->vset (&h, pos, val);
|
||||
scm_array_handle_release (&h);
|
||||
}
|
||||
|
@ -846,6 +844,12 @@ array_get_handle (SCM array, scm_t_array_handle *h)
|
|||
{
|
||||
scm_t_array_handle vh;
|
||||
scm_array_get_handle (SCM_I_ARRAY_V (array), &vh);
|
||||
if (vh.dims[0].inc != 1 || vh.dims[0].lbnd != 0 || vh.base != 0)
|
||||
{
|
||||
fprintf(stderr, "INC %ld, %ld", vh.dims[0].inc, vh.dims[0].lbnd);
|
||||
fflush(stderr);
|
||||
abort();
|
||||
}
|
||||
h->element_type = vh.element_type;
|
||||
h->elements = vh.elements;
|
||||
h->writable_elements = vh.writable_elements;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue