unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* gab-buffer issue
@ 2014-06-27 13:22 Mario Domenech Goulart
  2014-06-27 14:06 ` Mark H Weaver
  0 siblings, 1 reply; 3+ messages in thread
From: Mario Domenech Goulart @ 2014-06-27 13:22 UTC (permalink / raw)
  To: guile-devel; +Cc: ttn

Hi,

I'm using the CHICKEN port [1] of Guile's gap-buffer implementation and
noticed a strange behavior in a simple test case.  I can reproduce that
behavior on Guile 2.0.5 and 2.0.9, but not on Guile 2.0.11.

[1] http://wiki.call-cc.org/eggref/4/gap-buffer

Here's the test case:

$ cat guile-gap-buffer.scm
(use-modules (ice-9 gap-buffer))

(define buffer (make-gap-buffer ""))

(define data
  "aaaaa\nbbbbb\nccccc\nddddd\neeeee\nffff\nggggg\nhhhhh\niiiii\njjjjj\nkkkkk\nlllll\n")

(gb-insert-string! buffer data)

(display "Before goto-char: ")
(newline)
(display (gb->string buffer))
(newline)

(gb-goto-char buffer 1)

(display "After goto-char:")
(newline)
(display (gb->string buffer))
(newline)

$ guile -s guile-gap-buffer.scm
Before goto-char: 
aaaaa
bbbbb
ccccc
ddddd
eeeee
ffff
ggggg
hhhhh
iiiii
jjjjj
kkkkk
lllll

After goto-char:
aaaaa
bbbbb
ccccc
ddddd
eeeee
ffff
ggggg
hhhhh
iiiii
jjjjaaaaa
bbbbb
cc

$ guile --version
guile (GNU Guile) 2.0.5-deb+1-3
Copyright (C) 2011 Free Software Foundation, Inc.

License LGPLv3+: GNU LGPL 3 or later
<http://gnu.org/licenses/lgpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


With Guile 2.0.11 I get the expected behavior:

$ ~/local/guile-2.0.11/bin/guile -s guile-gap-buffer.scm
Before goto-char: 
aaaaa
bbbbb
ccccc
ddddd
eeeee
ffff
ggggg
hhhhh
iiiii
jjjjj
kkkkk
lllll

After goto-char:
aaaaa
bbbbb
ccccc
ddddd
eeeee
ffff
ggggg
hhhhh
iiiii
jjjjj
kkkkk
lllll


Do you know what may be causing the behavior observed with CHICKEN and
older Guile versions?

Best wishes.
Mario
-- 
http://parenteses.org/mario



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gab-buffer issue
  2014-06-27 13:22 gab-buffer issue Mario Domenech Goulart
@ 2014-06-27 14:06 ` Mark H Weaver
  2014-06-27 18:08   ` Mario Domenech Goulart
  0 siblings, 1 reply; 3+ messages in thread
From: Mark H Weaver @ 2014-06-27 14:06 UTC (permalink / raw)
  To: Mario Domenech Goulart; +Cc: ttn, guile-devel

Hi Mario,

Mario Domenech Goulart <mario.goulart@gmail.com> writes:
> I'm using the CHICKEN port [1] of Guile's gap-buffer implementation and
> noticed a strange behavior in a simple test case.  I can reproduce that
> behavior on Guile 2.0.5 and 2.0.9, but not on Guile 2.0.11.

In Guile versions 2.0.0 - 2.0.9, there was a bug in 'string-copy!' such
that it did not work properly when the source and destination ranges
overlapped.  The characters were always copied starting from the lowest
index, so it would fail when moving a block of characters to higher
indices.  'string-copy!' is used by 'substring-move!', which in turn is
used by 'gb-goto-char'.

The bug was introduced in f846bd1a8f0e0d366fb8bb6944598641bc3dd246 when
the SRFI-13 functions were updated for Unicode, and fixed in
793e8a9317d24298c82389bdf86b8ca17b4ee2f0.

    Regards,
      Mark



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gab-buffer issue
  2014-06-27 14:06 ` Mark H Weaver
@ 2014-06-27 18:08   ` Mario Domenech Goulart
  0 siblings, 0 replies; 3+ messages in thread
From: Mario Domenech Goulart @ 2014-06-27 18:08 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: ttn, guile-devel

On Fri, 27 Jun 2014 10:06:48 -0400 Mark H Weaver <mhw@netris.org> wrote:

> Mario Domenech Goulart <mario.goulart@gmail.com> writes:
>> I'm using the CHICKEN port [1] of Guile's gap-buffer implementation and
>> noticed a strange behavior in a simple test case.  I can reproduce that
>> behavior on Guile 2.0.5 and 2.0.9, but not on Guile 2.0.11.
>
> In Guile versions 2.0.0 - 2.0.9, there was a bug in 'string-copy!' such
> that it did not work properly when the source and destination ranges
> overlapped.  The characters were always copied starting from the lowest
> index, so it would fail when moving a block of characters to higher
> indices.  'string-copy!' is used by 'substring-move!', which in turn is
> used by 'gb-goto-char'.
>
> The bug was introduced in f846bd1a8f0e0d366fb8bb6944598641bc3dd246 when
> the SRFI-13 functions were updated for Unicode, and fixed in
> 793e8a9317d24298c82389bdf86b8ca17b4ee2f0.

Many thanks for the detailed and straight-to-the-point info, Mark.  It
looks like CHICKEN's string-copy! is buggy.  I've locally applied a fix
to it and can confirm it fixes the gap-buffer issue.

Best wishes.
Mario
-- 
http://parenteses.org/mario



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-27 18:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-27 13:22 gab-buffer issue Mario Domenech Goulart
2014-06-27 14:06 ` Mark H Weaver
2014-06-27 18:08   ` Mario Domenech Goulart

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).