Bruce Korb <[email protected]> writes:
> On 01/07/12 07:00, Mark H Weaver wrote:
>> The right place to fix this would probably be in
>> `scm_i_string_start_writing' (strings.c).
>
> I think it too much effort for that function. I looked at it.
> The problem is that you'd have to pass it the start and end points,
> that is, change its interface.
Ah yes, excellent point!
Indeed, it would not be enough for `scm_i_string_start_writing' to check
for an empty string. Even for non-empty immutable strings, if the range
of character indices passed to a string mutator is empty, then no
characters will be changed, and therefore the operation should succeed.
`scm_i_string_start_writing' doesn't have enough information to detect
this case.
I see two choices:
* Modify the interface to `scm_i_string_start_writing' to give it the
`start' and `end' indices.
* Add checks to all string mutation functions: if the range is empty,
then avoid calling `scm_i_string_start_writing'.
The advantage to the first approach is that authors of future string
mutators won't have to remember to handle this case specially, and I
have very little confidence that they would.
I'll look into this.
Mark