Fix bug #15841 with missing line numbers in linum-mode.

src/search.c (find_newline): If buffer text is relocated during the
 "dumb loop", adjust C pointers into buffer text to follow suit.
This commit is contained in:
Eli Zaretskii 2013-11-09 23:24:10 +02:00
parent b24ac90f5d
commit 85f37d1011
2 changed files with 34 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2013-11-09 Eli Zaretskii <eliz@gnu.org>
* search.c (find_newline): If buffer text is relocated during the
"dumb loop", adjust C pointers into buffer text to follow suit.
(Bug#15841)
2013-11-09 Łukasz Stelmach <stlman@poczta.fm> (tiny change)
* gtkutil.c (xg_check_special_colors): Use rgb: instead of rgbi:

View file

@ -752,6 +752,22 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
*bytepos = nl + 1 - base + start_byte;
return BYTE_TO_CHAR (nl + 1 - base + start_byte);
}
if (newline_cache)
{
/* The call to know_region_cache could have
allocated memory and caused relocation of buffer
text. If it did, adjust pointers into buffer
text. */
ptrdiff_t offset = BYTE_POS_ADDR (start_byte) - base;
if (offset != 0)
{
cursor += offset;
base += offset;
ceiling_addr += offset;
nl += offset;
}
}
cursor = nl + 1;
}
@ -824,6 +840,18 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
*bytepos = nl - base + start_byte;
return BYTE_TO_CHAR (nl - base + start_byte);
}
if (newline_cache)
{
ptrdiff_t offset = BYTE_POS_ADDR (start_byte - 1) - base;
if (offset != 0)
{
cursor += offset;
base += offset;
ceiling_addr += offset;
nl += offset;
}
}
cursor = nl - 1;
}