Fix off-by-one error when initializing vectors in `make-srfi-4-vector'.

* libguile/srfi-4.c (scm_make_srfi_4_vector): When FILL is bound and
  non-zero, initialize the last element.

* test-suite/tests/srfi-4.test ("TAG vectors")["make-TAGvector"]: New
  tests.
This commit is contained in:
Ludovic Courtès 2010-03-02 23:16:26 +01:00
commit d900a8557d
2 changed files with 56 additions and 10 deletions

View file

@ -267,9 +267,15 @@ SCM_DEFINE (scm_make_srfi_4_vector, "make-srfi-4-vector", 2, 1, 0,
scm_t_array_handle h;
size_t len;
ssize_t pos, inc;
scm_uniform_vector_writable_elements (ret, &h, &len, &inc);
for (pos = 0; pos != h.dims[0].ubnd; pos += inc)
scm_array_handle_set (&h, pos, fill);
/* Initialize the last element. */
scm_array_handle_set (&h, pos, fill);
scm_array_handle_release (&h);
}
return ret;