[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] GNU Guile branch, branch_release-1-8, updated. release_1
From: |
Andy Wingo |
Subject: |
[Guile-commits] GNU Guile branch, branch_release-1-8, updated. release_1-8-7-29-g3de9a08 |
Date: |
Thu, 05 Aug 2010 14:22:17 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=3de9a08715a499079a9e22ea76a688a6c5381b42
The branch, branch_release-1-8 has been updated
via 3de9a08715a499079a9e22ea76a688a6c5381b42 (commit)
from 5c8c9d05aea1f4d65ae926321ead0b77e05e3f1c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3de9a08715a499079a9e22ea76a688a6c5381b42
Author: Andy Wingo <address@hidden>
Date: Wed Aug 4 21:48:00 2010 +0200
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.
-----------------------------------------------------------------------
Summary of changes:
libguile/vectors.c | 12 +++++--
test-suite/tests/vectors.test | 81 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 89 insertions(+), 4 deletions(-)
diff --git a/libguile/vectors.c b/libguile/vectors.c
index eeb8569..074655c 100644
--- a/libguile/vectors.c
+++ b/libguile/vectors.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2006, 2008 Free Software
Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2006, 2008, 2010 Free Software
Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -465,7 +465,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;
@@ -503,7 +505,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;
diff --git a/test-suite/tests/vectors.test b/test-suite/tests/vectors.test
index 738a082..c350992 100644
--- a/test-suite/tests/vectors.test
+++ b/test-suite/tests/vectors.test
@@ -1,6 +1,6 @@
;;;; vectors.test --- test suite for Guile's vector functions -*- scheme -*-
;;;;
-;;;; Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+;;;; Copyright (C) 2003, 2006, 2010 Free Software Foundation, Inc.
;;;;
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
@@ -41,3 +41,82 @@
(let ((b (make-shared-array #(1) (lambda (x) '(0)) 2)))
(equal? b (list->vector (vector->list b))))))
+(with-test-prefix "vector-move-left!"
+
+ (pass-if-exception "before start" exception:out-of-range
+ (let ((a (vector 1 2 3 4 5 6 7 8 9))
+ (b (vector 10 20 30 40 50 60 70 80 90)))
+ (vector-move-left! a 3 5 b -1)))
+
+ (pass-if "beginning"
+ (let ((a (vector 1 2 3 4 5 6 7 8 9))
+ (b (vector 10 20 30 40 50 60 70 80 90)))
+ (vector-move-left! a 3 5 b 0)
+ (equal? b #(4 5 30 40 50 60 70 80 90))))
+
+ (pass-if "middle"
+ (let ((a (vector 1 2 3 4 5 6 7 8 9))
+ (b (vector 10 20 30 40 50 60 70 80 90)))
+ (vector-move-left! a 3 5 b 2)
+ (equal? b #(10 20 4 5 50 60 70 80 90))))
+
+ (pass-if "overlap -"
+ (let ((a (vector 1 2 3 4 5 6 7 8 9)))
+ (vector-move-left! a 3 5 a 2)
+ (equal? a #(1 2 4 5 5 6 7 8 9))))
+
+ (pass-if "overlap +"
+ (let ((a (vector 1 2 3 4 5 6 7 8 9)))
+ (vector-move-left! a 3 5 a 4)
+ (equal? a #(1 2 3 4 4 4 7 8 9))))
+
+ (pass-if "end"
+ (let ((a (vector 1 2 3 4 5 6 7 8 9))
+ (b (vector 10 20 30 40 50 60 70 80 90)))
+ (vector-move-left! a 3 5 b 7)
+ (equal? b #(10 20 30 40 50 60 70 4 5))))
+
+ (pass-if-exception "past end" exception:out-of-range
+ (let ((a (vector 1 2 3 4 5 6 7 8 9))
+ (b (vector 10 20 30 40 50 60 70 80 90)))
+ (vector-move-left! a 3 5 b 8))))
+
+(with-test-prefix "vector-move-right!"
+
+ (pass-if-exception "before start" exception:out-of-range
+ (let ((a (vector 1 2 3 4 5 6 7 8 9))
+ (b (vector 10 20 30 40 50 60 70 80 90)))
+ (vector-move-right! a 3 5 b -1)))
+
+ (pass-if "beginning"
+ (let ((a (vector 1 2 3 4 5 6 7 8 9))
+ (b (vector 10 20 30 40 50 60 70 80 90)))
+ (vector-move-right! a 3 5 b 0)
+ (equal? b #(4 5 30 40 50 60 70 80 90))))
+
+ (pass-if "middle"
+ (let ((a (vector 1 2 3 4 5 6 7 8 9))
+ (b (vector 10 20 30 40 50 60 70 80 90)))
+ (vector-move-right! a 3 5 b 2)
+ (equal? b #(10 20 4 5 50 60 70 80 90))))
+
+ (pass-if "overlap -"
+ (let ((a (vector 1 2 3 4 5 6 7 8 9)))
+ (vector-move-right! a 3 5 a 2)
+ (equal? a #(1 2 5 5 5 6 7 8 9))))
+
+ (pass-if "overlap +"
+ (let ((a (vector 1 2 3 4 5 6 7 8 9)))
+ (vector-move-right! a 3 5 a 4)
+ (equal? a #(1 2 3 4 4 5 7 8 9))))
+
+ (pass-if "end"
+ (let ((a (vector 1 2 3 4 5 6 7 8 9))
+ (b (vector 10 20 30 40 50 60 70 80 90)))
+ (vector-move-right! a 3 5 b 7)
+ (equal? b #(10 20 30 40 50 60 70 4 5))))
+
+ (pass-if-exception "past end" exception:out-of-range
+ (let ((a (vector 1 2 3 4 5 6 7 8 9))
+ (b (vector 10 20 30 40 50 60 70 80 90)))
+ (vector-move-right! a 3 5 b 8))))
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, branch_release-1-8, updated. release_1-8-7-29-g3de9a08,
Andy Wingo <=