Allow overlapping regions to be passed to `bytevector-copy!'.

Reported by Dmitry Chestnykh <dmitry@codingrobots.com>.
Fixes <http://debbugs.gnu.org/10070>.

* libguile/bytevectors.c (scm_bytevector_copy_x): Use `memmove', not
  `memcpy'.

* test-suite/tests/bytevectors.test ("2.2 General
  Operations")["bytevector-copy! overlapping"]: New test.

* doc/ref/api-data.texi (Bytevector Manipulation): Mention possible
  overlapping.
This commit is contained in:
Ludovic Courtès 2011-11-20 01:10:58 +01:00
commit 8071964943
3 changed files with 14 additions and 6 deletions

View file

@ -4546,7 +4546,8 @@ Fill bytevector @var{bv} with @var{fill}, a byte.
@deffnx {C Function} scm_bytevector_copy_x (source, source_start, target, target_start, len)
Copy @var{len} bytes from @var{source} into @var{target}, starting
reading from @var{source-start} (a positive index within @var{source})
and start writing at @var{target-start}.
and start writing at @var{target-start}. It is permitted for the
@var{source} and @var{target} regions to overlap.
@end deffn
@deffn {Scheme Procedure} bytevector-copy bv