diff options
| author | Eli Zaretskii | 2013-11-18 18:29:49 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2013-11-18 18:29:49 +0200 |
| commit | 37c790b38599cc80a16c6a76152abbf8160fe2a1 (patch) | |
| tree | a2f40d0acba8cdcf5c6502f4c07093f138772887 /src | |
| parent | f2cbfd4442bf194bd277101357a86f96707ec36c (diff) | |
| download | emacs-37c790b38599cc80a16c6a76152abbf8160fe2a1.tar.gz emacs-37c790b38599cc80a16c6a76152abbf8160fe2a1.zip | |
Fix bug #15841 with assertion violations due to newline cache.
src/insdel.c (invalidate_buffer_caches): New function, consolidated
from part of prepare_to_modify_buffer.
(insert_from_gap, prepare_to_modify_buffer):
src/coding.c (code_convert_region, code_convert_string): Call
invalidate_buffer_caches.
src/lisp.h (invalidate_buffer_caches): Add prototype.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/coding.c | 17 | ||||
| -rw-r--r-- | src/insdel.c | 36 | ||||
| -rw-r--r-- | src/lisp.h | 1 |
4 files changed, 52 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 2b88d076b8c..a2dfa5bf613 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2013-11-18 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * insdel.c (invalidate_buffer_caches): New function, consolidated | ||
| 4 | from part of prepare_to_modify_buffer. | ||
| 5 | (insert_from_gap, prepare_to_modify_buffer): | ||
| 6 | * coding.c (code_convert_region, code_convert_string): Call | ||
| 7 | invalidate_buffer_caches. (Bug#15841) | ||
| 8 | |||
| 9 | * lisp.h (invalidate_buffer_caches): Add prototype. | ||
| 10 | |||
| 1 | 2013-11-17 Eli Zaretskii <eliz@gnu.org> | 11 | 2013-11-17 Eli Zaretskii <eliz@gnu.org> |
| 2 | 12 | ||
| 3 | * w32term.c (x_update_window_end): Don't invalidate the entire | 13 | * w32term.c (x_update_window_end): Don't invalidate the entire |
diff --git a/src/coding.c b/src/coding.c index ac828a48683..6c0633f2d93 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -9358,6 +9358,14 @@ code_convert_region (Lisp_Object start, Lisp_Object end, | |||
| 9358 | setup_coding_system (coding_system, &coding); | 9358 | setup_coding_system (coding_system, &coding); |
| 9359 | coding.mode |= CODING_MODE_LAST_BLOCK; | 9359 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 9360 | 9360 | ||
| 9361 | if (BUFFERP (dst_object) && !EQ (dst_object, src_object)) | ||
| 9362 | { | ||
| 9363 | struct buffer *buf = XBUFFER (dst_object); | ||
| 9364 | ptrdiff_t buf_pt = BUF_PT (buf); | ||
| 9365 | |||
| 9366 | invalidate_buffer_caches (buf, buf_pt, buf_pt); | ||
| 9367 | } | ||
| 9368 | |||
| 9361 | if (encodep) | 9369 | if (encodep) |
| 9362 | encode_coding_object (&coding, src_object, from, from_byte, to, to_byte, | 9370 | encode_coding_object (&coding, src_object, from, from_byte, to, to_byte, |
| 9363 | dst_object); | 9371 | dst_object); |
| @@ -9447,6 +9455,15 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system, | |||
| 9447 | coding.mode |= CODING_MODE_LAST_BLOCK; | 9455 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 9448 | chars = SCHARS (string); | 9456 | chars = SCHARS (string); |
| 9449 | bytes = SBYTES (string); | 9457 | bytes = SBYTES (string); |
| 9458 | |||
| 9459 | if (BUFFERP (dst_object)) | ||
| 9460 | { | ||
| 9461 | struct buffer *buf = XBUFFER (dst_object); | ||
| 9462 | ptrdiff_t buf_pt = BUF_PT (buf); | ||
| 9463 | |||
| 9464 | invalidate_buffer_caches (buf, buf_pt, buf_pt); | ||
| 9465 | } | ||
| 9466 | |||
| 9450 | if (encodep) | 9467 | if (encodep) |
| 9451 | encode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object); | 9468 | encode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object); |
| 9452 | else | 9469 | else |
diff --git a/src/insdel.c b/src/insdel.c index 5515b641d66..8de4f095396 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -993,6 +993,11 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes, bool text_at_gap_tail) | |||
| 993 | if (NILP (BVAR (current_buffer, enable_multibyte_characters))) | 993 | if (NILP (BVAR (current_buffer, enable_multibyte_characters))) |
| 994 | nchars = nbytes; | 994 | nchars = nbytes; |
| 995 | 995 | ||
| 996 | /* No need to call prepare_to_modify_buffer, since this is called | ||
| 997 | from places that replace some region with a different text, so | ||
| 998 | prepare_to_modify_buffer was already called by the deletion part | ||
| 999 | of this dance. */ | ||
| 1000 | invalidate_buffer_caches (current_buffer, GPT, GPT); | ||
| 996 | record_insert (GPT, nchars); | 1001 | record_insert (GPT, nchars); |
| 997 | MODIFF++; | 1002 | MODIFF++; |
| 998 | 1003 | ||
| @@ -1869,19 +1874,26 @@ prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end, | |||
| 1869 | ptrdiff_t *preserve_ptr) | 1874 | ptrdiff_t *preserve_ptr) |
| 1870 | { | 1875 | { |
| 1871 | prepare_to_modify_buffer_1 (start, end, preserve_ptr); | 1876 | prepare_to_modify_buffer_1 (start, end, preserve_ptr); |
| 1877 | invalidate_buffer_caches (current_buffer, start, end); | ||
| 1878 | } | ||
| 1872 | 1879 | ||
| 1873 | if (current_buffer->newline_cache) | 1880 | /* Invalidate the caches maintained by the buffer BUF, if any, for the |
| 1874 | invalidate_region_cache (current_buffer, | 1881 | region between buffer positions START and END. */ |
| 1875 | current_buffer->newline_cache, | 1882 | void |
| 1876 | start - BEG, Z - end); | 1883 | invalidate_buffer_caches (struct buffer *buf, ptrdiff_t start, ptrdiff_t end) |
| 1877 | if (current_buffer->width_run_cache) | 1884 | { |
| 1878 | invalidate_region_cache (current_buffer, | 1885 | if (buf->newline_cache) |
| 1879 | current_buffer->width_run_cache, | 1886 | invalidate_region_cache (buf, |
| 1880 | start - BEG, Z - end); | 1887 | buf->newline_cache, |
| 1881 | if (current_buffer->bidi_paragraph_cache) | 1888 | start - BUF_BEG (buf), BUF_Z (buf) - end); |
| 1882 | invalidate_region_cache (current_buffer, | 1889 | if (buf->width_run_cache) |
| 1883 | current_buffer->bidi_paragraph_cache, | 1890 | invalidate_region_cache (buf, |
| 1884 | start - BEG, Z - end); | 1891 | buf->width_run_cache, |
| 1892 | start - BUF_BEG (buf), BUF_Z (buf) - end); | ||
| 1893 | if (buf->bidi_paragraph_cache) | ||
| 1894 | invalidate_region_cache (buf, | ||
| 1895 | buf->bidi_paragraph_cache, | ||
| 1896 | start - BUF_BEG (buf), BUF_Z (buf) - end); | ||
| 1885 | } | 1897 | } |
| 1886 | 1898 | ||
| 1887 | /* These macros work with an argument named `preserve_ptr' | 1899 | /* These macros work with an argument named `preserve_ptr' |
diff --git a/src/lisp.h b/src/lisp.h index 926b83d7ce0..a5aec41be38 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3479,6 +3479,7 @@ extern Lisp_Object del_range_2 (ptrdiff_t, ptrdiff_t, | |||
| 3479 | extern void modify_text (ptrdiff_t, ptrdiff_t); | 3479 | extern void modify_text (ptrdiff_t, ptrdiff_t); |
| 3480 | extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *); | 3480 | extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *); |
| 3481 | extern void prepare_to_modify_buffer_1 (ptrdiff_t, ptrdiff_t, ptrdiff_t *); | 3481 | extern void prepare_to_modify_buffer_1 (ptrdiff_t, ptrdiff_t, ptrdiff_t *); |
| 3482 | extern void invalidate_buffer_caches (struct buffer *, ptrdiff_t, ptrdiff_t); | ||
| 3482 | extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t); | 3483 | extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t); |
| 3483 | extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t, | 3484 | extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t, |
| 3484 | ptrdiff_t, ptrdiff_t); | 3485 | ptrdiff_t, ptrdiff_t); |