Mercurial > emacs
changeset 77017:484daf850d1e
(Ftranspose_regions): Validate interval before setting text
properties.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 07 Apr 2007 03:37:48 +0000 |
parents | 5bc043f16661 |
children | 35ca16426f7c |
files | src/editfns.c |
diffstat | 1 files changed, 20 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/editfns.c Sat Apr 07 03:37:37 2007 +0000 +++ b/src/editfns.c Sat Apr 07 03:37:48 2007 +0000 @@ -4119,7 +4119,7 @@ int gap, len1, len_mid, len2; unsigned char *start1_addr, *start2_addr, *temp; - INTERVAL cur_intv, tmp_interval1, tmp_interval_mid, tmp_interval2; + INTERVAL cur_intv, tmp_interval1, tmp_interval_mid, tmp_interval2, tmp_interval3; Lisp_Object buf; XSETBUFFER (buf, current_buffer); @@ -4231,8 +4231,9 @@ tmp_interval2 = copy_intervals (cur_intv, start2, len2); /* Don't use Fset_text_properties: that can cause GC, which can clobber objects stored in the tmp_intervals. */ - set_text_properties_1 (make_number (start1), make_number (end2), - Qnil, buf, NULL); + tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0); + if (!NULL_INTERVAL_P (tmp_interval3)) + set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); /* First region smaller than second. */ if (len1_byte < len2_byte) @@ -4288,10 +4289,14 @@ record_change (start2, len2); tmp_interval1 = copy_intervals (cur_intv, start1, len1); tmp_interval2 = copy_intervals (cur_intv, start2, len2); - set_text_properties_1 (make_number (start1), make_number (end1), - Qnil, buf, NULL); - set_text_properties_1 (make_number (start2), make_number (end2), - Qnil, buf, NULL); + + tmp_interval3 = validate_interval_range (buf, &startr1, &endr1, 0); + if (!NULL_INTERVAL_P (tmp_interval3)) + set_text_properties_1 (startr1, endr1, Qnil, buf, tmp_interval3); + + tmp_interval3 = validate_interval_range (buf, &startr2, &endr2, 0); + if (!NULL_INTERVAL_P (tmp_interval3)) + set_text_properties_1 (startr2, endr2, Qnil, buf, tmp_interval3); SAFE_ALLOCA (temp, unsigned char *, len1_byte); start1_addr = BYTE_POS_ADDR (start1_byte); @@ -4317,8 +4322,10 @@ tmp_interval1 = copy_intervals (cur_intv, start1, len1); tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); tmp_interval2 = copy_intervals (cur_intv, start2, len2); - set_text_properties_1 (make_number (start1), make_number (end2), - Qnil, buf, NULL); + + tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0); + if (!NULL_INTERVAL_P (tmp_interval3)) + set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); /* holds region 2 */ SAFE_ALLOCA (temp, unsigned char *, len2_byte); @@ -4348,8 +4355,10 @@ tmp_interval1 = copy_intervals (cur_intv, start1, len1); tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); tmp_interval2 = copy_intervals (cur_intv, start2, len2); - set_text_properties_1 (make_number (start1), make_number (end2), - Qnil, buf, NULL); + + tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0); + if (!NULL_INTERVAL_P (tmp_interval3)) + set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); /* holds region 1 */ SAFE_ALLOCA (temp, unsigned char *, len1_byte);