diff options
author | Ludovic Courtès <ludo@gnu.org> | 2010-03-02 23:16:26 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2010-03-02 23:16:26 +0100 |
commit | d900a8557db21641413db8995a7cdc1453adbe1f (patch) | |
tree | 11fd4f557af18f02ac762493feb65332edcaa0fb /libguile/srfi-4.c | |
parent | 69c9600678e67a51b258f2e3cfe1b5e0f842b45d (diff) | |
download | guile-d900a8557db21641413db8995a7cdc1453adbe1f.tar.gz |
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.
Diffstat (limited to 'libguile/srfi-4.c')
-rw-r--r-- | libguile/srfi-4.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libguile/srfi-4.c b/libguile/srfi-4.c index 005a5a089..cb92b80c7 100644 --- a/libguile/srfi-4.c +++ b/libguile/srfi-4.c @@ -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; |