mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-18 17:50:29 +02:00
fix vector-move-right! and vector-move-left!
* libguile/vectors.c (scm_vector_move_left_x, scm_vector_move_right_x): Fix some bugs reported by Michael Lucy -- both variants would happily write beyond the end, and vector-move-right! didn't increment the counter before copying in the reverse direction. * test-suite/tests/vectors.test ("vector-move-left!"): ("vector-move-right!"): Add tests.
This commit is contained in:
parent
f9560a348e
commit
551b96d294
2 changed files with 88 additions and 3 deletions
|
@ -533,7 +533,9 @@ SCM_DEFINE (scm_vector_move_left_x, "vector-move-left!", 5, 0, 0,
|
|||
|
||||
i = scm_to_unsigned_integer (start1, 0, len1);
|
||||
e = scm_to_unsigned_integer (end1, i, len1);
|
||||
j = scm_to_unsigned_integer (start2, 0, len2 - (i-e));
|
||||
SCM_ASSERT_RANGE (SCM_ARG3, end1, (e-i) < len2);
|
||||
j = scm_to_unsigned_integer (start2, 0, len2);
|
||||
SCM_ASSERT_RANGE (SCM_ARG5, start2, j <= len2 - (e - i));
|
||||
|
||||
i *= inc1;
|
||||
e *= inc1;
|
||||
|
@ -571,7 +573,11 @@ SCM_DEFINE (scm_vector_move_right_x, "vector-move-right!", 5, 0, 0,
|
|||
|
||||
i = scm_to_unsigned_integer (start1, 0, len1);
|
||||
e = scm_to_unsigned_integer (end1, i, len1);
|
||||
j = scm_to_unsigned_integer (start2, 0, len2 - (i-e));
|
||||
SCM_ASSERT_RANGE (SCM_ARG3, end1, (e-i) < len2);
|
||||
j = scm_to_unsigned_integer (start2, 0, len2);
|
||||
SCM_ASSERT_RANGE (SCM_ARG5, start2, j <= len2 - (e - i));
|
||||
|
||||
j += (e - i);
|
||||
|
||||
i *= inc1;
|
||||
e *= inc1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue