[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug in vector-move-right!
From: |
Michael Lucy |
Subject: |
Bug in vector-move-right! |
Date: |
Fri, 26 Mar 2010 01:06:06 -0600 |
Hi,
I think there's a bug in vector-move-right!. I'm using guile 1.9.9 as
built from the git repository earlier today.
This is the behavior I see:
"
scheme@(guile-user)> (define *v1* #(1 2 3 4 5 6 7 8 9))
scheme@(guile-user)> (define *v2* #(10 20 30 40 50 60 70 80 90))
scheme@(guile-user)> (vector-move-right! *v1* 0 2 *v2* 5)
scheme@(guile-user)> *v2*
#(10 20 30 1 2 60 70 80 90)
"
It seems to interpret the argument start2 as an ending index. I
thought for a second that this might be intended behavior, but it says
in the documentation that start2 is supposed to be an inclusive index,
which it isn't.
This is the behavior I expect:
"
scheme@(guile-user)> (define *v1* #(1 2 3 4 5 6 7 8 9))
scheme@(guile-user)> (define *v2* #(10 20 30 40 50 60 70 80 90))
scheme@(guile-user)> (vector-move-right! *v1* 0 2 *v2* 5)
scheme@(guile-user)> *v2*
#(10 20 30 40 50 1 2 80 90)
"
This is also the behavior already shown by vector-move-left! in the
same context.
If this is actually a bug rather than a documentation issue, it can be
fixed by adding one line to libguile/vectors.c. Here's a diff:
diff -c /home/zededarian/bak/vectors.c.old
/home/zededarian/gg/libguile/vectors.c
*** /home/zededarian/bak/vectors.c.old 2010-03-25 16:41:48.000000000 -0500
--- /home/zededarian/gg/libguile/vectors.c 2010-03-26
01:37:52.000000000 -0500
***************
*** 573,578 ****
--- 573,580 ----
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));
+
+ j += (e - i);
i *= inc1;
e *= inc1;
Diff finished. Fri Mar 26 02:03:05 2010
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Bug in vector-move-right!,
Michael Lucy <=