Opened 6 years ago

Closed 6 years ago

#1135 closed defect (fixed)

string-copy! bug

Reported by: Mario Domenech Goulart Owned by:
Priority: major Milestone: 4.10.0
Component: core libraries Version: 4.9.x
Keywords: string-copy!, srfi-13 Cc:
Estimated difficulty:

Description

While using the gap-buffer egg (implementation ported from Guile), I noticed a weird behavior in certain cases (see http://lists.gnu.org/archive/html/guile-devel/2014-06/msg00060.html)

Looks like the culprit is string-copy! (probably C_substring_copy), as it was in Guile's case (as pointed by Mark H Weaver).

A test case from Guile's test suite illustrates the problem:

(let ((str (string-copy "abcde")))
  (string-copy! str 1 str 0 3) str)
=> "aaaae"

Expected: "aabce"

Attachments (2)

0001-C_substring_copy-use-C_memmove-instead-of-C_memcpy-w.patch (3.0 KB) - added by Mario Domenech Goulart 6 years ago.
0001-C_substring_copy-use-C_memmove-instead-of-C_memcpy.patch (2.6 KB) - added by Mario Domenech Goulart 6 years ago.

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by Mario Domenech Goulart

comment:1 Changed 6 years ago by Mario Domenech Goulart

The attached patch Works For Me, although I don't know if it is the optimal/correct solution.

Changed 6 years ago by Mario Domenech Goulart

comment:2 Changed 6 years ago by Mario Domenech Goulart

Seth Alves pointed out on #chicken that checking for string equality is pointless, since memmove will do that anyway. So, attached is a new patch which just replaces C_memcpy by C_memmove in C_substring_copy.

comment:3 Changed 6 years ago by sjamaan

Resolution: fixed
Status: newclosed

Fixed by 6b36695d94e0bd977e0d85d48438f621128e1101

Note: See TracTickets for help on using tickets.