From: Eli Zaretskii Date: Sat, 9 Nov 2013 21:24:10 +0000 (+0200) Subject: Fix bug #15841 with missing line numbers in linum-mode. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~879 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=85f37d101104e812c545d6ae9275508bc20c8fe1;p=emacs.git 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. --- diff --git a/src/ChangeLog b/src/ChangeLog index 5ff279a4400..9a485533266 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2013-11-09 Eli Zaretskii + + * 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 (tiny change) * gtkutil.c (xg_check_special_colors): Use rgb: instead of rgbi: diff --git a/src/search.c b/src/search.c index 99e8d2501fe..1d0740428d7 100644 --- a/src/search.c +++ b/src/search.c @@ -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; }