const unsigned char *add_stuff = NULL;
ptrdiff_t add_len = 0;
ptrdiff_t idx = -1;
+ ptrdiff_t begbyte;
if (str_multibyte)
{
set up ADD_STUFF and ADD_LEN to point to it. */
if (idx >= 0)
{
- ptrdiff_t begbyte = CHAR_TO_BYTE (search_regs.start[idx]);
+ begbyte = CHAR_TO_BYTE (search_regs.start[idx]);
add_len = CHAR_TO_BYTE (search_regs.end[idx]) - begbyte;
if (search_regs.start[idx] < GPT && GPT < search_regs.end[idx])
move_gap_both (search_regs.start[idx], begbyte);
- add_stuff = BYTE_POS_ADDR (begbyte);
}
/* Now the stuff we want to add to SUBSTED
add_len - (substed_alloc_size - substed_len),
STRING_BYTES_BOUND, 1);
+ /* We compute this after the call to xpalloc, because that
+ could cause buffer text be relocated when ralloc.c is used. */
+ if (idx >= 0)
+ add_stuff = BYTE_POS_ADDR (begbyte);
+
/* Now add to the end of SUBSTED. */
if (add_stuff)
{