unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Michael Lucy <MichaelGLucy@Gmail.com>
To: bug-guile@gnu.org
Subject: Bug in vector-move-right!
Date: Fri, 26 Mar 2010 01:06:06 -0600	[thread overview]
Message-ID: <52c42c3e1003260006o71310c3en51c92d91f5cc4e0a@mail.gmail.com> (raw)

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




             reply	other threads:[~2010-03-26  7:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-26  7:06 Michael Lucy [this message]
2010-08-04 19:48 ` Bug in vector-move-right! Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52c42c3e1003260006o71310c3en51c92d91f5cc4e0a@mail.gmail.com \
    --to=michaelglucy@gmail.com \
    --cc=bug-guile@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).