aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2012-09-14 18:23:50 +0400
committerDmitry Antipov2012-09-14 18:23:50 +0400
commit2f294edf3a601c612e0a4c208539e842d790a894 (patch)
tree3f4d64a1bacb904a2406c3f2d73b79c8f1d913a9 /src
parent0fb3cb7c8921f6ad3ac59c24d608384be91d5baa (diff)
downloademacs-2f294edf3a601c612e0a4c208539e842d790a894.tar.gz
emacs-2f294edf3a601c612e0a4c208539e842d790a894.zip
Avoid out-of-range marker position (Bug#12426).
* insdel.c (replace_range, replace_range_2): Adjust markers before overlays, as suggested by comments. (insert_1_both, insert_from_buffer_1, adjust_after_replace): Remove redundant check before calling offset_intervals.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/insdel.c31
2 files changed, 22 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5cda8241916..27698886079 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12012-09-14 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Avoid out-of-range marker position (Bug#12426).
4 * insdel.c (replace_range, replace_range_2): Adjust
5 markers before overlays, as suggested by comments.
6 (insert_1_both, insert_from_buffer_1, adjust_after_replace):
7 Remove redundant check before calling offset_intervals.
8
12012-09-14 Martin Rudalics <rudalics@gmx.at> 92012-09-14 Martin Rudalics <rudalics@gmx.at>
2 10
3 * xdisp.c (Fformat_mode_line): Unconditionally save/restore 11 * xdisp.c (Fformat_mode_line): Unconditionally save/restore
diff --git a/src/insdel.c b/src/insdel.c
index b12a390633e..bfb2327a696 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -840,8 +840,7 @@ insert_1_both (const char *string,
840 PT + nchars, PT_BYTE + nbytes, 840 PT + nchars, PT_BYTE + nbytes,
841 before_markers); 841 before_markers);
842 842
843 if (buffer_intervals (current_buffer)) 843 offset_intervals (current_buffer, PT, nchars);
844 offset_intervals (current_buffer, PT, nchars);
845 844
846 if (!inherit && buffer_intervals (current_buffer)) 845 if (!inherit && buffer_intervals (current_buffer))
847 set_text_properties (make_number (PT), make_number (PT + nchars), 846 set_text_properties (make_number (PT), make_number (PT + nchars),
@@ -1153,8 +1152,7 @@ insert_from_buffer_1 (struct buffer *buf,
1153 PT_BYTE + outgoing_nbytes, 1152 PT_BYTE + outgoing_nbytes,
1154 0); 1153 0);
1155 1154
1156 if (buffer_intervals (current_buffer)) 1155 offset_intervals (current_buffer, PT, nchars);
1157 offset_intervals (current_buffer, PT, nchars);
1158 1156
1159 /* Get the intervals for the part of the string we are inserting. */ 1157 /* Get the intervals for the part of the string we are inserting. */
1160 intervals = buffer_intervals (buf); 1158 intervals = buffer_intervals (buf);
@@ -1222,8 +1220,7 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte,
1222 else if (len < nchars_del) 1220 else if (len < nchars_del)
1223 adjust_overlays_for_delete (from, nchars_del - len); 1221 adjust_overlays_for_delete (from, nchars_del - len);
1224 1222
1225 if (buffer_intervals (current_buffer)) 1223 offset_intervals (current_buffer, from, len - nchars_del);
1226 offset_intervals (current_buffer, from, len - nchars_del);
1227 1224
1228 if (from < PT) 1225 if (from < PT)
1229 adjust_point (len - nchars_del, len_byte - nbytes_del); 1226 adjust_point (len - nchars_del, len_byte - nbytes_del);
@@ -1394,16 +1391,16 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
1394 1391
1395 eassert (GPT <= GPT_BYTE); 1392 eassert (GPT <= GPT_BYTE);
1396 1393
1397 /* Adjust the overlay center as needed. This must be done after
1398 adjusting the markers that bound the overlays. */
1399 adjust_overlays_for_delete (from, nchars_del);
1400 adjust_overlays_for_insert (from, inschars);
1401
1402 /* Adjust markers for the deletion and the insertion. */ 1394 /* Adjust markers for the deletion and the insertion. */
1403 if (markers) 1395 if (markers)
1404 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, 1396 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1405 inschars, outgoing_insbytes); 1397 inschars, outgoing_insbytes);
1406 1398
1399 /* Adjust the overlay center as needed. This must be done after
1400 adjusting the markers that bound the overlays. */
1401 adjust_overlays_for_delete (from, nchars_del);
1402 adjust_overlays_for_insert (from, inschars);
1403
1407 offset_intervals (current_buffer, from, inschars - nchars_del); 1404 offset_intervals (current_buffer, from, inschars - nchars_del);
1408 1405
1409 /* Get the intervals for the part of the string we are inserting-- 1406 /* Get the intervals for the part of the string we are inserting--
@@ -1510,6 +1507,12 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1510 1507
1511 eassert (GPT <= GPT_BYTE); 1508 eassert (GPT <= GPT_BYTE);
1512 1509
1510 /* Adjust markers for the deletion and the insertion. */
1511 if (markers
1512 && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes))
1513 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1514 inschars, insbytes);
1515
1513 /* Adjust the overlay center as needed. This must be done after 1516 /* Adjust the overlay center as needed. This must be done after
1514 adjusting the markers that bound the overlays. */ 1517 adjusting the markers that bound the overlays. */
1515 if (nchars_del != inschars) 1518 if (nchars_del != inschars)
@@ -1518,12 +1521,6 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1518 adjust_overlays_for_delete (from + inschars, nchars_del); 1521 adjust_overlays_for_delete (from + inschars, nchars_del);
1519 } 1522 }
1520 1523
1521 /* Adjust markers for the deletion and the insertion. */
1522 if (markers
1523 && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes))
1524 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1525 inschars, insbytes);
1526
1527 offset_intervals (current_buffer, from, inschars - nchars_del); 1524 offset_intervals (current_buffer, from, inschars - nchars_del);
1528 1525
1529 /* Relocate point as if it were a marker. */ 1526 /* Relocate point as if it were a marker. */